mirror of https://github.com/waku-org/js-waku.git
Migrate from ts-proto to protons
The latter does not bring Buffer/Long and is ESM compatible.
This commit is contained in:
parent
1bfc72fa2a
commit
82aba32f9e
File diff suppressed because it is too large
Load Diff
|
@ -45,9 +45,7 @@
|
|||
"test:unit": "nyc --silent mocha",
|
||||
"test:karma": "karma start karma.conf.cjs",
|
||||
"examples:test": "run-s examples:pretest; for d in examples/*/; do (cd $d && npm test;); done",
|
||||
"proto": "run-s proto:*",
|
||||
"proto:lint": "buf lint",
|
||||
"proto:build": "rimraf ./src/proto && buf generate",
|
||||
"proto": "rimraf src/proto/*.ts; protons src/proto/*.proto",
|
||||
"watch:build": "tsc -p tsconfig.json -w",
|
||||
"watch:test": "nyc --silent mocha --watch",
|
||||
"doc": "run-s doc:*",
|
||||
|
@ -82,11 +80,10 @@
|
|||
"libp2p-interfaces": "^4.0.6",
|
||||
"libp2p-mplex": "^0.10.4",
|
||||
"libp2p-websockets": "^0.16.1",
|
||||
"long": "^4.0.0",
|
||||
"multiaddr": "^10.0.1",
|
||||
"multiformats": "^9.6.5",
|
||||
"peer-id": "^0.16.0",
|
||||
"protobufjs": "^6.8.8",
|
||||
"protons-runtime": "^1.0.4",
|
||||
"uint8arrays": "^3.0.0",
|
||||
"uuid": "^8.3.2",
|
||||
"varint": "^6.0.0"
|
||||
|
@ -133,13 +130,13 @@
|
|||
"portfinder": "^1.0.28",
|
||||
"prettier": "^2.1.1",
|
||||
"process": "^0.11.10",
|
||||
"protons": "^3.0.4",
|
||||
"puppeteer": "^13.0.1",
|
||||
"size-limit": "^7.0.8",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"tail": "^2.2.0",
|
||||
"ts-loader": "^9.2.6",
|
||||
"ts-node": "^10.4.0",
|
||||
"ts-proto": "^1.82.5",
|
||||
"typedoc": "^0.22.10",
|
||||
"typedoc-plugin-no-inherit": "^1.3.1",
|
||||
"typescript": "^4.5.5",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Reader } from "protobufjs/minimal";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
import * as proto from "../../proto/waku/v2/filter";
|
||||
import * as proto from "../../proto/filter";
|
||||
|
||||
export type ContentFilter = {
|
||||
contentTopic: string;
|
||||
|
@ -36,7 +35,7 @@ export class FilterRPC {
|
|||
* @returns FilterRPC
|
||||
*/
|
||||
static decode(bytes: Uint8Array): FilterRPC {
|
||||
const res = proto.FilterRPC.decode(Reader.create(bytes));
|
||||
const res = proto.FilterRPC.decode(bytes);
|
||||
return new FilterRPC(res);
|
||||
}
|
||||
|
||||
|
@ -45,7 +44,7 @@ export class FilterRPC {
|
|||
* @returns Uint8Array
|
||||
*/
|
||||
encode(): Uint8Array {
|
||||
return proto.FilterRPC.encode(this.proto).finish();
|
||||
return proto.FilterRPC.encode(this.proto);
|
||||
}
|
||||
|
||||
get push(): proto.MessagePush | undefined {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { pipe } from "it-pipe";
|
|||
import Libp2p, { MuxedStream } from "libp2p";
|
||||
import { Peer, PeerId } from "libp2p/src/peer-store";
|
||||
|
||||
import { WakuMessage as WakuMessageProto } from "../../proto/waku/v2/message";
|
||||
import { WakuMessage as WakuMessageProto } from "../../proto/message";
|
||||
import { DefaultPubSubTopic } from "../constants";
|
||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||
import { hexToBytes } from "../utils";
|
||||
|
|
|
@ -5,7 +5,7 @@ import Libp2p from "libp2p";
|
|||
import { Peer } from "libp2p/src/peer-store";
|
||||
import PeerId from "peer-id";
|
||||
|
||||
import { PushResponse } from "../../proto/waku/v2/light_push";
|
||||
import { PushResponse } from "../../proto/light_push";
|
||||
import { DefaultPubSubTopic } from "../constants";
|
||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||
import { WakuMessage } from "../waku_message";
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import protobufjs from "protobufjs/minimal";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
import * as proto from "../../proto/waku/v2/light_push";
|
||||
import * as proto from "../../proto/light_push";
|
||||
import { WakuMessage } from "../waku_message";
|
||||
|
||||
const { Reader } = protobufjs;
|
||||
|
||||
export class PushRPC {
|
||||
public constructor(public proto: proto.PushRPC) {}
|
||||
|
||||
|
@ -21,12 +18,12 @@ export class PushRPC {
|
|||
}
|
||||
|
||||
static decode(bytes: Uint8Array): PushRPC {
|
||||
const res = proto.PushRPC.decode(Reader.create(bytes));
|
||||
const res = proto.PushRPC.decode(bytes);
|
||||
return new PushRPC(res);
|
||||
}
|
||||
|
||||
encode(): Uint8Array {
|
||||
return proto.PushRPC.encode(this.proto).finish();
|
||||
return proto.PushRPC.encode(this.proto);
|
||||
}
|
||||
|
||||
get query(): proto.PushRequest | undefined {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
import debug from "debug";
|
||||
import Long from "long";
|
||||
import protobufjs from "protobufjs/minimal";
|
||||
|
||||
import * as proto from "../../proto/waku/v2/message";
|
||||
import * as proto from "../../proto/message";
|
||||
import { bytesToUtf8, utf8ToBytes } from "../utils";
|
||||
|
||||
import * as version_1 from "./version_1";
|
||||
|
||||
const { Reader } = protobufjs;
|
||||
const DefaultVersion = 0;
|
||||
const dbg = debug("waku:message");
|
||||
|
||||
|
@ -106,7 +103,7 @@ export class WakuMessage {
|
|||
payload: _payload,
|
||||
timestampDeprecated: timestamp.valueOf() / 1000,
|
||||
// milliseconds 10^-3 to nanoseconds 10^-9
|
||||
timestamp: Long.fromNumber(timestamp.valueOf()).mul(1_000_000),
|
||||
timestamp: BigInt(timestamp.valueOf()) * BigInt(1_000_000),
|
||||
version,
|
||||
contentTopic,
|
||||
},
|
||||
|
@ -132,7 +129,7 @@ export class WakuMessage {
|
|||
contentTopic?: string[];
|
||||
}>
|
||||
): Promise<WakuMessage | undefined> {
|
||||
const protoBuf = proto.WakuMessage.decode(Reader.create(bytes));
|
||||
const protoBuf = proto.WakuMessage.decode(bytes);
|
||||
|
||||
return WakuMessage.decodeProto(protoBuf, decryptionKeys);
|
||||
}
|
||||
|
@ -249,7 +246,7 @@ export class WakuMessage {
|
|||
}
|
||||
|
||||
encode(): Uint8Array {
|
||||
return proto.WakuMessage.encode(this.proto).finish();
|
||||
return proto.WakuMessage.encode(this.proto);
|
||||
}
|
||||
|
||||
get payloadAsUtf8(): string {
|
||||
|
@ -286,8 +283,8 @@ export class WakuMessage {
|
|||
try {
|
||||
if (this.proto.timestamp) {
|
||||
// nanoseconds 10^-9 to milliseconds 10^-3
|
||||
const timestamp = this.proto.timestamp.div(1_000_000).toNumber();
|
||||
return new Date(timestamp);
|
||||
const timestamp = this.proto.timestamp / BigInt(1_000_000);
|
||||
return new Date(Number(timestamp));
|
||||
}
|
||||
|
||||
if (this.proto.timestampDeprecated) {
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import Long from "long";
|
||||
import protobufjs from "protobufjs/minimal";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
import * as protoV2Beta3 from "../../proto/waku/v2/store/v2beta3/store";
|
||||
import * as protoV2Beta4 from "../../proto/waku/v2/store/v2beta4/store";
|
||||
import * as protoV2Beta3 from "../../proto/store_v2beta3";
|
||||
import * as protoV2Beta4 from "../../proto/store_v2beta4";
|
||||
|
||||
import { StoreCodecs } from "./constants";
|
||||
|
||||
const { Reader } = protobufjs;
|
||||
const OneMillion = BigInt(1_000_000);
|
||||
|
||||
export enum PageDirection {
|
||||
BACKWARD = "backward",
|
||||
|
@ -26,7 +24,9 @@ export interface Params {
|
|||
}
|
||||
|
||||
export class HistoryRPC {
|
||||
private readonly protoCodec: any;
|
||||
private readonly historyRpc:
|
||||
| typeof protoV2Beta3.HistoryRPC
|
||||
| typeof protoV2Beta4.HistoryRPC;
|
||||
|
||||
private constructor(
|
||||
public readonly proto: protoV2Beta3.HistoryRPC | protoV2Beta4.HistoryRPC,
|
||||
|
@ -34,10 +34,10 @@ export class HistoryRPC {
|
|||
) {
|
||||
switch (storeCodec) {
|
||||
case StoreCodecs.V2Beta3:
|
||||
this.protoCodec = protoV2Beta3;
|
||||
this.historyRpc = protoV2Beta3.HistoryRPC;
|
||||
break;
|
||||
case StoreCodecs.V2Beta4:
|
||||
this.protoCodec = protoV2Beta4;
|
||||
this.historyRpc = protoV2Beta4.HistoryRPC;
|
||||
break;
|
||||
default:
|
||||
throw `Internal Error: Unexpected store codec value received in constructor: ${storeCodec}`;
|
||||
|
@ -75,7 +75,7 @@ export class HistoryRPC {
|
|||
// Using function to scope variables
|
||||
return ((): HistoryRPC => {
|
||||
const pagingInfo = {
|
||||
pageSize: Long.fromNumber(params.pageSize),
|
||||
pageSize: BigInt(params.pageSize),
|
||||
cursor: params.cursor,
|
||||
direction,
|
||||
} as protoV2Beta3.PagingInfo;
|
||||
|
@ -103,7 +103,7 @@ export class HistoryRPC {
|
|||
case StoreCodecs.V2Beta4:
|
||||
return ((): HistoryRPC => {
|
||||
const pagingInfo = {
|
||||
pageSize: Long.fromNumber(params.pageSize),
|
||||
pageSize: BigInt(params.pageSize),
|
||||
cursor: params.cursor,
|
||||
direction,
|
||||
} as protoV2Beta4.PagingInfo;
|
||||
|
@ -111,14 +111,12 @@ export class HistoryRPC {
|
|||
let startTime, endTime;
|
||||
if (params.startTime) {
|
||||
// milliseconds 10^-3 to nanoseconds 10^-9
|
||||
startTime = Long.fromNumber(params.startTime.valueOf()).mul(
|
||||
1_000_000
|
||||
);
|
||||
startTime = BigInt(params.startTime.valueOf()) * OneMillion;
|
||||
}
|
||||
|
||||
if (params.endTime) {
|
||||
// milliseconds 10^-3 to nanoseconds 10^-9
|
||||
endTime = Long.fromNumber(params.endTime.valueOf()).mul(1_000_000);
|
||||
endTime = BigInt(params.endTime.valueOf()) * OneMillion;
|
||||
}
|
||||
return new HistoryRPC(
|
||||
{
|
||||
|
@ -142,24 +140,24 @@ export class HistoryRPC {
|
|||
}
|
||||
|
||||
decode(bytes: Uint8Array): HistoryRPC {
|
||||
const res = this.protoCodec.HistoryRPC.decode(Reader.create(bytes));
|
||||
const res = this.historyRpc.decode(bytes);
|
||||
return new HistoryRPC(res, this.storeCodec);
|
||||
}
|
||||
|
||||
encode(): Uint8Array {
|
||||
return this.protoCodec.HistoryRPC.encode(this.proto).finish();
|
||||
return this.historyRpc.encode(this.proto as any);
|
||||
}
|
||||
}
|
||||
|
||||
function directionToProto(
|
||||
pageDirection: PageDirection
|
||||
): protoV2Beta4.PagingInfo_Direction {
|
||||
): protoV2Beta4.PagingInfo.Direction {
|
||||
switch (pageDirection) {
|
||||
case PageDirection.BACKWARD:
|
||||
return protoV2Beta4.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||
return protoV2Beta4.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||
case PageDirection.FORWARD:
|
||||
return protoV2Beta4.PagingInfo_Direction.DIRECTION_FORWARD;
|
||||
return protoV2Beta4.PagingInfo.Direction.DIRECTION_FORWARD;
|
||||
default:
|
||||
return protoV2Beta4.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||
return protoV2Beta4.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import Libp2p from "libp2p";
|
|||
import { Peer } from "libp2p/src/peer-store";
|
||||
import PeerId from "peer-id";
|
||||
|
||||
import * as protoV2Beta4 from "../../proto/store_v2beta4";
|
||||
import { DefaultPubSubTopic, StoreCodecs } from "../constants";
|
||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||
import { hexToBytes } from "../utils";
|
||||
|
@ -211,11 +212,12 @@ export class WakuStore {
|
|||
);
|
||||
const reply = historyRpcQuery.decode(res.slice());
|
||||
|
||||
const response = reply.response;
|
||||
if (!response) {
|
||||
if (!reply.response) {
|
||||
throw "History response misses response field";
|
||||
}
|
||||
|
||||
const response = reply.response as protoV2Beta4.HistoryResponse;
|
||||
|
||||
if (response.error) {
|
||||
throw "History response contains an Error" + response.error;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package waku.v2;
|
||||
|
||||
import "waku/v2/message.proto";
|
||||
import "message.proto";
|
||||
|
||||
message FilterRequest {
|
||||
bool subscribe = 1;
|
||||
|
@ -20,6 +18,6 @@ message MessagePush {
|
|||
|
||||
message FilterRPC {
|
||||
string request_id = 1;
|
||||
FilterRequest request = 2;
|
||||
MessagePush push = 3;
|
||||
}
|
||||
optional FilterRequest request = 2;
|
||||
optional MessagePush push = 3;
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
string,
|
||||
bool,
|
||||
bytes,
|
||||
uint32,
|
||||
double,
|
||||
sint64,
|
||||
} from "protons-runtime";
|
||||
import type { Codec } from "protons-runtime";
|
||||
|
||||
export interface FilterRequest {
|
||||
subscribe: boolean;
|
||||
topic: string;
|
||||
contentFilters: FilterRequest.ContentFilter[];
|
||||
}
|
||||
|
||||
export namespace FilterRequest {
|
||||
export interface ContentFilter {
|
||||
contentTopic: string;
|
||||
}
|
||||
|
||||
export namespace ContentFilter {
|
||||
export const codec = (): Codec<ContentFilter> => {
|
||||
return message<ContentFilter>({
|
||||
1: { name: "contentTopic", codec: string },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: ContentFilter): Uint8Array => {
|
||||
return encodeMessage(obj, ContentFilter.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): ContentFilter => {
|
||||
return decodeMessage(buf, ContentFilter.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export const codec = (): Codec<FilterRequest> => {
|
||||
return message<FilterRequest>({
|
||||
1: { name: "subscribe", codec: bool },
|
||||
2: { name: "topic", codec: string },
|
||||
3: {
|
||||
name: "contentFilters",
|
||||
codec: FilterRequest.ContentFilter.codec(),
|
||||
repeats: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: FilterRequest): Uint8Array => {
|
||||
return encodeMessage(obj, FilterRequest.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): FilterRequest => {
|
||||
return decodeMessage(buf, FilterRequest.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface MessagePush {
|
||||
messages: WakuMessage[];
|
||||
}
|
||||
|
||||
export namespace MessagePush {
|
||||
export const codec = (): Codec<MessagePush> => {
|
||||
return message<MessagePush>({
|
||||
1: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: MessagePush): Uint8Array => {
|
||||
return encodeMessage(obj, MessagePush.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): MessagePush => {
|
||||
return decodeMessage(buf, MessagePush.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface FilterRPC {
|
||||
requestId: string;
|
||||
request?: FilterRequest;
|
||||
push?: MessagePush;
|
||||
}
|
||||
|
||||
export namespace FilterRPC {
|
||||
export const codec = (): Codec<FilterRPC> => {
|
||||
return message<FilterRPC>({
|
||||
1: { name: "requestId", codec: string },
|
||||
2: { name: "request", codec: FilterRequest.codec(), optional: true },
|
||||
3: { name: "push", codec: MessagePush.codec(), optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: FilterRPC): Uint8Array => {
|
||||
return encodeMessage(obj, FilterRPC.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): FilterRPC => {
|
||||
return decodeMessage(buf, FilterRPC.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
export const codec = (): Codec<WakuMessage> => {
|
||||
return message<WakuMessage>({
|
||||
1: { name: "payload", codec: bytes, optional: true },
|
||||
2: { name: "contentTopic", codec: string, optional: true },
|
||||
3: { name: "version", codec: uint32, optional: true },
|
||||
4: { name: "timestampDeprecated", codec: double, optional: true },
|
||||
10: { name: "timestamp", codec: sint64, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: WakuMessage): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessage.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessage => {
|
||||
return decodeMessage(buf, WakuMessage.codec());
|
||||
};
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package waku.v2;
|
||||
|
||||
import "waku/v2/message.proto";
|
||||
import "message.proto";
|
||||
|
||||
message PushRequest {
|
||||
string pub_sub_topic = 1;
|
||||
|
@ -16,6 +14,6 @@ message PushResponse {
|
|||
|
||||
message PushRPC {
|
||||
string request_id = 1;
|
||||
PushRequest request = 2;
|
||||
PushResponse response = 3;
|
||||
optional PushRequest request = 2;
|
||||
optional PushResponse response = 3;
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
string,
|
||||
bool,
|
||||
bytes,
|
||||
uint32,
|
||||
double,
|
||||
sint64,
|
||||
} from "protons-runtime";
|
||||
import type { Codec } from "protons-runtime";
|
||||
|
||||
export interface PushRequest {
|
||||
pubSubTopic: string;
|
||||
message: WakuMessage;
|
||||
}
|
||||
|
||||
export namespace PushRequest {
|
||||
export const codec = (): Codec<PushRequest> => {
|
||||
return message<PushRequest>({
|
||||
1: { name: "pubSubTopic", codec: string },
|
||||
2: { name: "message", codec: WakuMessage.codec() },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: PushRequest): Uint8Array => {
|
||||
return encodeMessage(obj, PushRequest.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): PushRequest => {
|
||||
return decodeMessage(buf, PushRequest.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface PushResponse {
|
||||
isSuccess: boolean;
|
||||
info: string;
|
||||
}
|
||||
|
||||
export namespace PushResponse {
|
||||
export const codec = (): Codec<PushResponse> => {
|
||||
return message<PushResponse>({
|
||||
1: { name: "isSuccess", codec: bool },
|
||||
2: { name: "info", codec: string },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: PushResponse): Uint8Array => {
|
||||
return encodeMessage(obj, PushResponse.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): PushResponse => {
|
||||
return decodeMessage(buf, PushResponse.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface PushRPC {
|
||||
requestId: string;
|
||||
request?: PushRequest;
|
||||
response?: PushResponse;
|
||||
}
|
||||
|
||||
export namespace PushRPC {
|
||||
export const codec = (): Codec<PushRPC> => {
|
||||
return message<PushRPC>({
|
||||
1: { name: "requestId", codec: string },
|
||||
2: { name: "request", codec: PushRequest.codec(), optional: true },
|
||||
3: { name: "response", codec: PushResponse.codec(), optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: PushRPC): Uint8Array => {
|
||||
return encodeMessage(obj, PushRPC.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): PushRPC => {
|
||||
return decodeMessage(buf, PushRPC.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
export const codec = (): Codec<WakuMessage> => {
|
||||
return message<WakuMessage>({
|
||||
1: { name: "payload", codec: bytes, optional: true },
|
||||
2: { name: "contentTopic", codec: string, optional: true },
|
||||
3: { name: "version", codec: uint32, optional: true },
|
||||
4: { name: "timestampDeprecated", codec: double, optional: true },
|
||||
10: { name: "timestamp", codec: sint64, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: WakuMessage): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessage.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessage => {
|
||||
return decodeMessage(buf, WakuMessage.codec());
|
||||
};
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package waku.v2;
|
||||
|
||||
message WakuMessage {
|
||||
optional bytes payload = 1;
|
||||
optional string content_topic = 2;
|
|
@ -0,0 +1,42 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
bytes,
|
||||
string,
|
||||
uint32,
|
||||
double,
|
||||
sint64,
|
||||
} from "protons-runtime";
|
||||
import type { Codec } from "protons-runtime";
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
export const codec = (): Codec<WakuMessage> => {
|
||||
return message<WakuMessage>({
|
||||
1: { name: "payload", codec: bytes, optional: true },
|
||||
2: { name: "contentTopic", codec: string, optional: true },
|
||||
3: { name: "version", codec: uint32, optional: true },
|
||||
4: { name: "timestampDeprecated", codec: double, optional: true },
|
||||
10: { name: "timestamp", codec: sint64, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: WakuMessage): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessage.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessage => {
|
||||
return decodeMessage(buf, WakuMessage.codec());
|
||||
};
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package waku.v2.store.v2beta3;
|
||||
|
||||
import "waku/v2/message.proto";
|
||||
import "message.proto";
|
||||
|
||||
message Index {
|
||||
bytes digest = 1;
|
||||
|
@ -44,6 +42,6 @@ message HistoryResponse {
|
|||
|
||||
message HistoryRPC {
|
||||
string request_id = 1;
|
||||
HistoryQuery query = 2;
|
||||
HistoryResponse response = 3;
|
||||
optional HistoryQuery query = 2;
|
||||
optional HistoryResponse response = 3;
|
||||
}
|
|
@ -0,0 +1,224 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
bytes,
|
||||
double,
|
||||
enumeration,
|
||||
uint64,
|
||||
string,
|
||||
uint32,
|
||||
sint64,
|
||||
} from "protons-runtime";
|
||||
import type { Codec } from "protons-runtime";
|
||||
|
||||
export interface Index {
|
||||
digest: Uint8Array;
|
||||
receivedTime: number;
|
||||
senderTime: number;
|
||||
}
|
||||
|
||||
export namespace Index {
|
||||
export const codec = (): Codec<Index> => {
|
||||
return message<Index>({
|
||||
1: { name: "digest", codec: bytes },
|
||||
2: { name: "receivedTime", codec: double },
|
||||
3: { name: "senderTime", codec: double },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: Index): Uint8Array => {
|
||||
return encodeMessage(obj, Index.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): Index => {
|
||||
return decodeMessage(buf, Index.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface PagingInfo {
|
||||
pageSize: bigint;
|
||||
cursor: Index;
|
||||
direction: PagingInfo.Direction;
|
||||
}
|
||||
|
||||
export namespace PagingInfo {
|
||||
export enum Direction {
|
||||
DIRECTION_BACKWARD_UNSPECIFIED = "DIRECTION_BACKWARD_UNSPECIFIED",
|
||||
DIRECTION_FORWARD = "DIRECTION_FORWARD",
|
||||
}
|
||||
|
||||
enum __DirectionValues {
|
||||
DIRECTION_BACKWARD_UNSPECIFIED = 0,
|
||||
DIRECTION_FORWARD = 1,
|
||||
}
|
||||
|
||||
export namespace Direction {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Direction>(__DirectionValues);
|
||||
};
|
||||
}
|
||||
|
||||
export const codec = (): Codec<PagingInfo> => {
|
||||
return message<PagingInfo>({
|
||||
1: { name: "pageSize", codec: uint64 },
|
||||
2: { name: "cursor", codec: Index.codec() },
|
||||
3: { name: "direction", codec: PagingInfo.Direction.codec() },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: PagingInfo): Uint8Array => {
|
||||
return encodeMessage(obj, PagingInfo.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): PagingInfo => {
|
||||
return decodeMessage(buf, PagingInfo.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface ContentFilter {
|
||||
contentTopic: string;
|
||||
}
|
||||
|
||||
export namespace ContentFilter {
|
||||
export const codec = (): Codec<ContentFilter> => {
|
||||
return message<ContentFilter>({
|
||||
1: { name: "contentTopic", codec: string },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: ContentFilter): Uint8Array => {
|
||||
return encodeMessage(obj, ContentFilter.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): ContentFilter => {
|
||||
return decodeMessage(buf, ContentFilter.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryQuery {
|
||||
pubSubTopic?: string;
|
||||
contentFilters: ContentFilter[];
|
||||
pagingInfo?: PagingInfo;
|
||||
startTime?: number;
|
||||
endTime?: number;
|
||||
}
|
||||
|
||||
export namespace HistoryQuery {
|
||||
export const codec = (): Codec<HistoryQuery> => {
|
||||
return message<HistoryQuery>({
|
||||
2: { name: "pubSubTopic", codec: string, optional: true },
|
||||
3: {
|
||||
name: "contentFilters",
|
||||
codec: ContentFilter.codec(),
|
||||
repeats: true,
|
||||
},
|
||||
4: { name: "pagingInfo", codec: PagingInfo.codec(), optional: true },
|
||||
5: { name: "startTime", codec: double, optional: true },
|
||||
6: { name: "endTime", codec: double, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: HistoryQuery): Uint8Array => {
|
||||
return encodeMessage(obj, HistoryQuery.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): HistoryQuery => {
|
||||
return decodeMessage(buf, HistoryQuery.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryResponse {
|
||||
messages: WakuMessage[];
|
||||
pagingInfo: PagingInfo;
|
||||
error: HistoryResponse.Error;
|
||||
}
|
||||
|
||||
export namespace HistoryResponse {
|
||||
export enum Error {
|
||||
ERROR_NONE_UNSPECIFIED = "ERROR_NONE_UNSPECIFIED",
|
||||
ERROR_INVALID_CURSOR = "ERROR_INVALID_CURSOR",
|
||||
}
|
||||
|
||||
enum __ErrorValues {
|
||||
ERROR_NONE_UNSPECIFIED = 0,
|
||||
ERROR_INVALID_CURSOR = 1,
|
||||
}
|
||||
|
||||
export namespace Error {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Error>(__ErrorValues);
|
||||
};
|
||||
}
|
||||
|
||||
export const codec = (): Codec<HistoryResponse> => {
|
||||
return message<HistoryResponse>({
|
||||
2: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
||||
3: { name: "pagingInfo", codec: PagingInfo.codec() },
|
||||
4: { name: "error", codec: HistoryResponse.Error.codec() },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: HistoryResponse): Uint8Array => {
|
||||
return encodeMessage(obj, HistoryResponse.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): HistoryResponse => {
|
||||
return decodeMessage(buf, HistoryResponse.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryRPC {
|
||||
requestId: string;
|
||||
query?: HistoryQuery;
|
||||
response?: HistoryResponse;
|
||||
}
|
||||
|
||||
export namespace HistoryRPC {
|
||||
export const codec = (): Codec<HistoryRPC> => {
|
||||
return message<HistoryRPC>({
|
||||
1: { name: "requestId", codec: string },
|
||||
2: { name: "query", codec: HistoryQuery.codec(), optional: true },
|
||||
3: { name: "response", codec: HistoryResponse.codec(), optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: HistoryRPC): Uint8Array => {
|
||||
return encodeMessage(obj, HistoryRPC.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): HistoryRPC => {
|
||||
return decodeMessage(buf, HistoryRPC.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
export const codec = (): Codec<WakuMessage> => {
|
||||
return message<WakuMessage>({
|
||||
1: { name: "payload", codec: bytes, optional: true },
|
||||
2: { name: "contentTopic", codec: string, optional: true },
|
||||
3: { name: "version", codec: uint32, optional: true },
|
||||
4: { name: "timestampDeprecated", codec: double, optional: true },
|
||||
10: { name: "timestamp", codec: sint64, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: WakuMessage): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessage.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessage => {
|
||||
return decodeMessage(buf, WakuMessage.codec());
|
||||
};
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package waku.v2.store.v2beta4;
|
||||
|
||||
import "waku/v2/message.proto";
|
||||
import "message.proto";
|
||||
|
||||
message Index {
|
||||
bytes digest = 1;
|
||||
|
@ -45,6 +43,6 @@ message HistoryResponse {
|
|||
|
||||
message HistoryRPC {
|
||||
string request_id = 1;
|
||||
HistoryQuery query = 2;
|
||||
HistoryResponse response = 3;
|
||||
optional HistoryQuery query = 2;
|
||||
optional HistoryResponse response = 3;
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import {
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
message,
|
||||
bytes,
|
||||
sint64,
|
||||
string,
|
||||
enumeration,
|
||||
uint64,
|
||||
uint32,
|
||||
double,
|
||||
} from "protons-runtime";
|
||||
import type { Codec } from "protons-runtime";
|
||||
|
||||
export interface Index {
|
||||
digest: Uint8Array;
|
||||
receivedTime: bigint;
|
||||
senderTime: bigint;
|
||||
pubsubTopic: string;
|
||||
}
|
||||
|
||||
export namespace Index {
|
||||
export const codec = (): Codec<Index> => {
|
||||
return message<Index>({
|
||||
1: { name: "digest", codec: bytes },
|
||||
2: { name: "receivedTime", codec: sint64 },
|
||||
3: { name: "senderTime", codec: sint64 },
|
||||
4: { name: "pubsubTopic", codec: string },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: Index): Uint8Array => {
|
||||
return encodeMessage(obj, Index.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): Index => {
|
||||
return decodeMessage(buf, Index.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface PagingInfo {
|
||||
pageSize: bigint;
|
||||
cursor: Index;
|
||||
direction: PagingInfo.Direction;
|
||||
}
|
||||
|
||||
export namespace PagingInfo {
|
||||
export enum Direction {
|
||||
DIRECTION_BACKWARD_UNSPECIFIED = "DIRECTION_BACKWARD_UNSPECIFIED",
|
||||
DIRECTION_FORWARD = "DIRECTION_FORWARD",
|
||||
}
|
||||
|
||||
enum __DirectionValues {
|
||||
DIRECTION_BACKWARD_UNSPECIFIED = 0,
|
||||
DIRECTION_FORWARD = 1,
|
||||
}
|
||||
|
||||
export namespace Direction {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Direction>(__DirectionValues);
|
||||
};
|
||||
}
|
||||
|
||||
export const codec = (): Codec<PagingInfo> => {
|
||||
return message<PagingInfo>({
|
||||
1: { name: "pageSize", codec: uint64 },
|
||||
2: { name: "cursor", codec: Index.codec() },
|
||||
3: { name: "direction", codec: PagingInfo.Direction.codec() },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: PagingInfo): Uint8Array => {
|
||||
return encodeMessage(obj, PagingInfo.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): PagingInfo => {
|
||||
return decodeMessage(buf, PagingInfo.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface ContentFilter {
|
||||
contentTopic: string;
|
||||
}
|
||||
|
||||
export namespace ContentFilter {
|
||||
export const codec = (): Codec<ContentFilter> => {
|
||||
return message<ContentFilter>({
|
||||
1: { name: "contentTopic", codec: string },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: ContentFilter): Uint8Array => {
|
||||
return encodeMessage(obj, ContentFilter.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): ContentFilter => {
|
||||
return decodeMessage(buf, ContentFilter.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryQuery {
|
||||
pubSubTopic?: string;
|
||||
contentFilters: ContentFilter[];
|
||||
pagingInfo?: PagingInfo;
|
||||
startTime?: bigint;
|
||||
endTime?: bigint;
|
||||
}
|
||||
|
||||
export namespace HistoryQuery {
|
||||
export const codec = (): Codec<HistoryQuery> => {
|
||||
return message<HistoryQuery>({
|
||||
2: { name: "pubSubTopic", codec: string, optional: true },
|
||||
3: {
|
||||
name: "contentFilters",
|
||||
codec: ContentFilter.codec(),
|
||||
repeats: true,
|
||||
},
|
||||
4: { name: "pagingInfo", codec: PagingInfo.codec(), optional: true },
|
||||
5: { name: "startTime", codec: sint64, optional: true },
|
||||
6: { name: "endTime", codec: sint64, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: HistoryQuery): Uint8Array => {
|
||||
return encodeMessage(obj, HistoryQuery.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): HistoryQuery => {
|
||||
return decodeMessage(buf, HistoryQuery.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryResponse {
|
||||
messages: WakuMessage[];
|
||||
pagingInfo: PagingInfo;
|
||||
error: HistoryResponse.Error;
|
||||
}
|
||||
|
||||
export namespace HistoryResponse {
|
||||
export enum Error {
|
||||
ERROR_NONE_UNSPECIFIED = "ERROR_NONE_UNSPECIFIED",
|
||||
ERROR_INVALID_CURSOR = "ERROR_INVALID_CURSOR",
|
||||
}
|
||||
|
||||
enum __ErrorValues {
|
||||
ERROR_NONE_UNSPECIFIED = 0,
|
||||
ERROR_INVALID_CURSOR = 1,
|
||||
}
|
||||
|
||||
export namespace Error {
|
||||
export const codec = () => {
|
||||
return enumeration<typeof Error>(__ErrorValues);
|
||||
};
|
||||
}
|
||||
|
||||
export const codec = (): Codec<HistoryResponse> => {
|
||||
return message<HistoryResponse>({
|
||||
2: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
||||
3: { name: "pagingInfo", codec: PagingInfo.codec() },
|
||||
4: { name: "error", codec: HistoryResponse.Error.codec() },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: HistoryResponse): Uint8Array => {
|
||||
return encodeMessage(obj, HistoryResponse.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): HistoryResponse => {
|
||||
return decodeMessage(buf, HistoryResponse.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryRPC {
|
||||
requestId: string;
|
||||
query?: HistoryQuery;
|
||||
response?: HistoryResponse;
|
||||
}
|
||||
|
||||
export namespace HistoryRPC {
|
||||
export const codec = (): Codec<HistoryRPC> => {
|
||||
return message<HistoryRPC>({
|
||||
1: { name: "requestId", codec: string },
|
||||
2: { name: "query", codec: HistoryQuery.codec(), optional: true },
|
||||
3: { name: "response", codec: HistoryResponse.codec(), optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: HistoryRPC): Uint8Array => {
|
||||
return encodeMessage(obj, HistoryRPC.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): HistoryRPC => {
|
||||
return decodeMessage(buf, HistoryRPC.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
export const codec = (): Codec<WakuMessage> => {
|
||||
return message<WakuMessage>({
|
||||
1: { name: "payload", codec: bytes, optional: true },
|
||||
2: { name: "contentTopic", codec: string, optional: true },
|
||||
3: { name: "version", codec: uint32, optional: true },
|
||||
4: { name: "timestampDeprecated", codec: double, optional: true },
|
||||
10: { name: "timestamp", codec: sint64, optional: true },
|
||||
});
|
||||
};
|
||||
|
||||
export const encode = (obj: WakuMessage): Uint8Array => {
|
||||
return encodeMessage(obj, WakuMessage.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array): WakuMessage => {
|
||||
return decodeMessage(buf, WakuMessage.codec());
|
||||
};
|
||||
}
|
|
@ -1,358 +0,0 @@
|
|||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import { WakuMessage } from "../../waku/v2/message";
|
||||
|
||||
export const protobufPackage = "waku.v2";
|
||||
|
||||
export interface FilterRequest {
|
||||
subscribe: boolean;
|
||||
topic: string;
|
||||
contentFilters: FilterRequest_ContentFilter[];
|
||||
}
|
||||
|
||||
export interface FilterRequest_ContentFilter {
|
||||
contentTopic: string;
|
||||
}
|
||||
|
||||
export interface MessagePush {
|
||||
messages: WakuMessage[];
|
||||
}
|
||||
|
||||
export interface FilterRPC {
|
||||
requestId: string;
|
||||
request: FilterRequest | undefined;
|
||||
push: MessagePush | undefined;
|
||||
}
|
||||
|
||||
function createBaseFilterRequest(): FilterRequest {
|
||||
return { subscribe: false, topic: "", contentFilters: [] };
|
||||
}
|
||||
|
||||
export const FilterRequest = {
|
||||
encode(
|
||||
message: FilterRequest,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.subscribe === true) {
|
||||
writer.uint32(8).bool(message.subscribe);
|
||||
}
|
||||
if (message.topic !== "") {
|
||||
writer.uint32(18).string(message.topic);
|
||||
}
|
||||
for (const v of message.contentFilters) {
|
||||
FilterRequest_ContentFilter.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): FilterRequest {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseFilterRequest();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.subscribe = reader.bool();
|
||||
break;
|
||||
case 2:
|
||||
message.topic = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.contentFilters.push(
|
||||
FilterRequest_ContentFilter.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): FilterRequest {
|
||||
return {
|
||||
subscribe: isSet(object.subscribe) ? Boolean(object.subscribe) : false,
|
||||
topic: isSet(object.topic) ? String(object.topic) : "",
|
||||
contentFilters: Array.isArray(object?.contentFilters)
|
||||
? object.contentFilters.map((e: any) =>
|
||||
FilterRequest_ContentFilter.fromJSON(e)
|
||||
)
|
||||
: [],
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: FilterRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.subscribe !== undefined && (obj.subscribe = message.subscribe);
|
||||
message.topic !== undefined && (obj.topic = message.topic);
|
||||
if (message.contentFilters) {
|
||||
obj.contentFilters = message.contentFilters.map((e) =>
|
||||
e ? FilterRequest_ContentFilter.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.contentFilters = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<FilterRequest>, I>>(
|
||||
object: I
|
||||
): FilterRequest {
|
||||
const message = createBaseFilterRequest();
|
||||
message.subscribe = object.subscribe ?? false;
|
||||
message.topic = object.topic ?? "";
|
||||
message.contentFilters =
|
||||
object.contentFilters?.map((e) =>
|
||||
FilterRequest_ContentFilter.fromPartial(e)
|
||||
) || [];
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseFilterRequest_ContentFilter(): FilterRequest_ContentFilter {
|
||||
return { contentTopic: "" };
|
||||
}
|
||||
|
||||
export const FilterRequest_ContentFilter = {
|
||||
encode(
|
||||
message: FilterRequest_ContentFilter,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.contentTopic !== "") {
|
||||
writer.uint32(10).string(message.contentTopic);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: _m0.Reader | Uint8Array,
|
||||
length?: number
|
||||
): FilterRequest_ContentFilter {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseFilterRequest_ContentFilter();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.contentTopic = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): FilterRequest_ContentFilter {
|
||||
return {
|
||||
contentTopic: isSet(object.contentTopic)
|
||||
? String(object.contentTopic)
|
||||
: "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: FilterRequest_ContentFilter): unknown {
|
||||
const obj: any = {};
|
||||
message.contentTopic !== undefined &&
|
||||
(obj.contentTopic = message.contentTopic);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<FilterRequest_ContentFilter>, I>>(
|
||||
object: I
|
||||
): FilterRequest_ContentFilter {
|
||||
const message = createBaseFilterRequest_ContentFilter();
|
||||
message.contentTopic = object.contentTopic ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseMessagePush(): MessagePush {
|
||||
return { messages: [] };
|
||||
}
|
||||
|
||||
export const MessagePush = {
|
||||
encode(
|
||||
message: MessagePush,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
for (const v of message.messages) {
|
||||
WakuMessage.encode(v!, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MessagePush {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseMessagePush();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.messages.push(WakuMessage.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MessagePush {
|
||||
return {
|
||||
messages: Array.isArray(object?.messages)
|
||||
? object.messages.map((e: any) => WakuMessage.fromJSON(e))
|
||||
: [],
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: MessagePush): unknown {
|
||||
const obj: any = {};
|
||||
if (message.messages) {
|
||||
obj.messages = message.messages.map((e) =>
|
||||
e ? WakuMessage.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.messages = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<MessagePush>, I>>(
|
||||
object: I
|
||||
): MessagePush {
|
||||
const message = createBaseMessagePush();
|
||||
message.messages =
|
||||
object.messages?.map((e) => WakuMessage.fromPartial(e)) || [];
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseFilterRPC(): FilterRPC {
|
||||
return { requestId: "", request: undefined, push: undefined };
|
||||
}
|
||||
|
||||
export const FilterRPC = {
|
||||
encode(
|
||||
message: FilterRPC,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.requestId !== "") {
|
||||
writer.uint32(10).string(message.requestId);
|
||||
}
|
||||
if (message.request !== undefined) {
|
||||
FilterRequest.encode(message.request, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.push !== undefined) {
|
||||
MessagePush.encode(message.push, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): FilterRPC {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseFilterRPC();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.requestId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.request = FilterRequest.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.push = MessagePush.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): FilterRPC {
|
||||
return {
|
||||
requestId: isSet(object.requestId) ? String(object.requestId) : "",
|
||||
request: isSet(object.request)
|
||||
? FilterRequest.fromJSON(object.request)
|
||||
: undefined,
|
||||
push: isSet(object.push) ? MessagePush.fromJSON(object.push) : undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: FilterRPC): unknown {
|
||||
const obj: any = {};
|
||||
message.requestId !== undefined && (obj.requestId = message.requestId);
|
||||
message.request !== undefined &&
|
||||
(obj.request = message.request
|
||||
? FilterRequest.toJSON(message.request)
|
||||
: undefined);
|
||||
message.push !== undefined &&
|
||||
(obj.push = message.push ? MessagePush.toJSON(message.push) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<FilterRPC>, I>>(
|
||||
object: I
|
||||
): FilterRPC {
|
||||
const message = createBaseFilterRPC();
|
||||
message.requestId = object.requestId ?? "";
|
||||
message.request =
|
||||
object.request !== undefined && object.request !== null
|
||||
? FilterRequest.fromPartial(object.request)
|
||||
: undefined;
|
||||
message.push =
|
||||
object.push !== undefined && object.push !== null
|
||||
? MessagePush.fromPartial(object.push)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Long
|
||||
? string | number | Long
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
||||
Exclude<keyof I, KeysOfUnion<P>>,
|
||||
never
|
||||
>;
|
||||
|
||||
if (_m0.util.Long !== Long) {
|
||||
_m0.util.Long = Long as any;
|
||||
_m0.configure();
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import { WakuMessage } from "../../waku/v2/message";
|
||||
|
||||
export const protobufPackage = "waku.v2";
|
||||
|
||||
export interface PushRequest {
|
||||
pubSubTopic: string;
|
||||
message: WakuMessage | undefined;
|
||||
}
|
||||
|
||||
export interface PushResponse {
|
||||
isSuccess: boolean;
|
||||
info: string;
|
||||
}
|
||||
|
||||
export interface PushRPC {
|
||||
requestId: string;
|
||||
request: PushRequest | undefined;
|
||||
response: PushResponse | undefined;
|
||||
}
|
||||
|
||||
function createBasePushRequest(): PushRequest {
|
||||
return { pubSubTopic: "", message: undefined };
|
||||
}
|
||||
|
||||
export const PushRequest = {
|
||||
encode(
|
||||
message: PushRequest,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.pubSubTopic !== "") {
|
||||
writer.uint32(10).string(message.pubSubTopic);
|
||||
}
|
||||
if (message.message !== undefined) {
|
||||
WakuMessage.encode(message.message, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PushRequest {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePushRequest();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.pubSubTopic = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.message = WakuMessage.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PushRequest {
|
||||
return {
|
||||
pubSubTopic: isSet(object.pubSubTopic) ? String(object.pubSubTopic) : "",
|
||||
message: isSet(object.message)
|
||||
? WakuMessage.fromJSON(object.message)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PushRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.pubSubTopic !== undefined &&
|
||||
(obj.pubSubTopic = message.pubSubTopic);
|
||||
message.message !== undefined &&
|
||||
(obj.message = message.message
|
||||
? WakuMessage.toJSON(message.message)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<PushRequest>, I>>(
|
||||
object: I
|
||||
): PushRequest {
|
||||
const message = createBasePushRequest();
|
||||
message.pubSubTopic = object.pubSubTopic ?? "";
|
||||
message.message =
|
||||
object.message !== undefined && object.message !== null
|
||||
? WakuMessage.fromPartial(object.message)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePushResponse(): PushResponse {
|
||||
return { isSuccess: false, info: "" };
|
||||
}
|
||||
|
||||
export const PushResponse = {
|
||||
encode(
|
||||
message: PushResponse,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.isSuccess === true) {
|
||||
writer.uint32(8).bool(message.isSuccess);
|
||||
}
|
||||
if (message.info !== "") {
|
||||
writer.uint32(18).string(message.info);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PushResponse {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePushResponse();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.isSuccess = reader.bool();
|
||||
break;
|
||||
case 2:
|
||||
message.info = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PushResponse {
|
||||
return {
|
||||
isSuccess: isSet(object.isSuccess) ? Boolean(object.isSuccess) : false,
|
||||
info: isSet(object.info) ? String(object.info) : "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PushResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.isSuccess !== undefined && (obj.isSuccess = message.isSuccess);
|
||||
message.info !== undefined && (obj.info = message.info);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<PushResponse>, I>>(
|
||||
object: I
|
||||
): PushResponse {
|
||||
const message = createBasePushResponse();
|
||||
message.isSuccess = object.isSuccess ?? false;
|
||||
message.info = object.info ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePushRPC(): PushRPC {
|
||||
return { requestId: "", request: undefined, response: undefined };
|
||||
}
|
||||
|
||||
export const PushRPC = {
|
||||
encode(
|
||||
message: PushRPC,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.requestId !== "") {
|
||||
writer.uint32(10).string(message.requestId);
|
||||
}
|
||||
if (message.request !== undefined) {
|
||||
PushRequest.encode(message.request, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.response !== undefined) {
|
||||
PushResponse.encode(message.response, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PushRPC {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePushRPC();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.requestId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.request = PushRequest.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.response = PushResponse.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PushRPC {
|
||||
return {
|
||||
requestId: isSet(object.requestId) ? String(object.requestId) : "",
|
||||
request: isSet(object.request)
|
||||
? PushRequest.fromJSON(object.request)
|
||||
: undefined,
|
||||
response: isSet(object.response)
|
||||
? PushResponse.fromJSON(object.response)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PushRPC): unknown {
|
||||
const obj: any = {};
|
||||
message.requestId !== undefined && (obj.requestId = message.requestId);
|
||||
message.request !== undefined &&
|
||||
(obj.request = message.request
|
||||
? PushRequest.toJSON(message.request)
|
||||
: undefined);
|
||||
message.response !== undefined &&
|
||||
(obj.response = message.response
|
||||
? PushResponse.toJSON(message.response)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<PushRPC>, I>>(object: I): PushRPC {
|
||||
const message = createBasePushRPC();
|
||||
message.requestId = object.requestId ?? "";
|
||||
message.request =
|
||||
object.request !== undefined && object.request !== null
|
||||
? PushRequest.fromPartial(object.request)
|
||||
: undefined;
|
||||
message.response =
|
||||
object.response !== undefined && object.response !== null
|
||||
? PushResponse.fromPartial(object.response)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Long
|
||||
? string | number | Long
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
||||
Exclude<keyof I, KeysOfUnion<P>>,
|
||||
never
|
||||
>;
|
||||
|
||||
if (_m0.util.Long !== Long) {
|
||||
_m0.util.Long = Long as any;
|
||||
_m0.configure();
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "waku.v2";
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array | undefined;
|
||||
contentTopic?: string | undefined;
|
||||
version?: number | undefined;
|
||||
timestampDeprecated?: number | undefined;
|
||||
timestamp?: Long | undefined;
|
||||
}
|
||||
|
||||
function createBaseWakuMessage(): WakuMessage {
|
||||
return {
|
||||
payload: undefined,
|
||||
contentTopic: undefined,
|
||||
version: undefined,
|
||||
timestampDeprecated: undefined,
|
||||
timestamp: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export const WakuMessage = {
|
||||
encode(
|
||||
message: WakuMessage,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.payload !== undefined) {
|
||||
writer.uint32(10).bytes(message.payload);
|
||||
}
|
||||
if (message.contentTopic !== undefined) {
|
||||
writer.uint32(18).string(message.contentTopic);
|
||||
}
|
||||
if (message.version !== undefined) {
|
||||
writer.uint32(24).uint32(message.version);
|
||||
}
|
||||
if (message.timestampDeprecated !== undefined) {
|
||||
writer.uint32(33).double(message.timestampDeprecated);
|
||||
}
|
||||
if (message.timestamp !== undefined) {
|
||||
writer.uint32(80).sint64(message.timestamp);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): WakuMessage {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseWakuMessage();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.payload = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.contentTopic = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.version = reader.uint32();
|
||||
break;
|
||||
case 4:
|
||||
message.timestampDeprecated = reader.double();
|
||||
break;
|
||||
case 10:
|
||||
message.timestamp = reader.sint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): WakuMessage {
|
||||
return {
|
||||
payload: isSet(object.payload)
|
||||
? bytesFromBase64(object.payload)
|
||||
: undefined,
|
||||
contentTopic: isSet(object.contentTopic)
|
||||
? String(object.contentTopic)
|
||||
: undefined,
|
||||
version: isSet(object.version) ? Number(object.version) : undefined,
|
||||
timestampDeprecated: isSet(object.timestampDeprecated)
|
||||
? Number(object.timestampDeprecated)
|
||||
: undefined,
|
||||
timestamp: isSet(object.timestamp)
|
||||
? Long.fromString(object.timestamp)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: WakuMessage): unknown {
|
||||
const obj: any = {};
|
||||
message.payload !== undefined &&
|
||||
(obj.payload =
|
||||
message.payload !== undefined
|
||||
? base64FromBytes(message.payload)
|
||||
: undefined);
|
||||
message.contentTopic !== undefined &&
|
||||
(obj.contentTopic = message.contentTopic);
|
||||
message.version !== undefined &&
|
||||
(obj.version = Math.round(message.version));
|
||||
message.timestampDeprecated !== undefined &&
|
||||
(obj.timestampDeprecated = message.timestampDeprecated);
|
||||
message.timestamp !== undefined &&
|
||||
(obj.timestamp = (message.timestamp || undefined).toString());
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<WakuMessage>, I>>(
|
||||
object: I
|
||||
): WakuMessage {
|
||||
const message = createBaseWakuMessage();
|
||||
message.payload = object.payload ?? undefined;
|
||||
message.contentTopic = object.contentTopic ?? undefined;
|
||||
message.version = object.version ?? undefined;
|
||||
message.timestampDeprecated = object.timestampDeprecated ?? undefined;
|
||||
message.timestamp =
|
||||
object.timestamp !== undefined && object.timestamp !== null
|
||||
? Long.fromValue(object.timestamp)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
declare var global: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (const byte of arr) {
|
||||
bin.push(String.fromCharCode(byte));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Long
|
||||
? string | number | Long
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
||||
Exclude<keyof I, KeysOfUnion<P>>,
|
||||
never
|
||||
>;
|
||||
|
||||
if (_m0.util.Long !== Long) {
|
||||
_m0.util.Long = Long as any;
|
||||
_m0.configure();
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
}
|
|
@ -1,704 +0,0 @@
|
|||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import { WakuMessage } from "../../../../waku/v2/message";
|
||||
|
||||
export const protobufPackage = "waku.v2.store.v2beta3";
|
||||
|
||||
export interface Index {
|
||||
digest: Uint8Array;
|
||||
receivedTime: number;
|
||||
senderTime: number;
|
||||
}
|
||||
|
||||
export interface PagingInfo {
|
||||
pageSize: Long;
|
||||
cursor: Index | undefined;
|
||||
direction: PagingInfo_Direction;
|
||||
}
|
||||
|
||||
export enum PagingInfo_Direction {
|
||||
DIRECTION_BACKWARD_UNSPECIFIED = 0,
|
||||
DIRECTION_FORWARD = 1,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function pagingInfo_DirectionFromJSON(
|
||||
object: any
|
||||
): PagingInfo_Direction {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "DIRECTION_BACKWARD_UNSPECIFIED":
|
||||
return PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||
case 1:
|
||||
case "DIRECTION_FORWARD":
|
||||
return PagingInfo_Direction.DIRECTION_FORWARD;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return PagingInfo_Direction.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function pagingInfo_DirectionToJSON(
|
||||
object: PagingInfo_Direction
|
||||
): string {
|
||||
switch (object) {
|
||||
case PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED:
|
||||
return "DIRECTION_BACKWARD_UNSPECIFIED";
|
||||
case PagingInfo_Direction.DIRECTION_FORWARD:
|
||||
return "DIRECTION_FORWARD";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContentFilter {
|
||||
contentTopic: string;
|
||||
}
|
||||
|
||||
export interface HistoryQuery {
|
||||
pubSubTopic?: string | undefined;
|
||||
contentFilters: ContentFilter[];
|
||||
pagingInfo?: PagingInfo | undefined;
|
||||
startTime?: number | undefined;
|
||||
endTime?: number | undefined;
|
||||
}
|
||||
|
||||
export interface HistoryResponse {
|
||||
messages: WakuMessage[];
|
||||
pagingInfo: PagingInfo | undefined;
|
||||
error: HistoryResponse_Error;
|
||||
}
|
||||
|
||||
export enum HistoryResponse_Error {
|
||||
ERROR_NONE_UNSPECIFIED = 0,
|
||||
ERROR_INVALID_CURSOR = 1,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function historyResponse_ErrorFromJSON(
|
||||
object: any
|
||||
): HistoryResponse_Error {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "ERROR_NONE_UNSPECIFIED":
|
||||
return HistoryResponse_Error.ERROR_NONE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "ERROR_INVALID_CURSOR":
|
||||
return HistoryResponse_Error.ERROR_INVALID_CURSOR;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return HistoryResponse_Error.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function historyResponse_ErrorToJSON(
|
||||
object: HistoryResponse_Error
|
||||
): string {
|
||||
switch (object) {
|
||||
case HistoryResponse_Error.ERROR_NONE_UNSPECIFIED:
|
||||
return "ERROR_NONE_UNSPECIFIED";
|
||||
case HistoryResponse_Error.ERROR_INVALID_CURSOR:
|
||||
return "ERROR_INVALID_CURSOR";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
export interface HistoryRPC {
|
||||
requestId: string;
|
||||
query: HistoryQuery | undefined;
|
||||
response: HistoryResponse | undefined;
|
||||
}
|
||||
|
||||
function createBaseIndex(): Index {
|
||||
return { digest: new Uint8Array(), receivedTime: 0, senderTime: 0 };
|
||||
}
|
||||
|
||||
export const Index = {
|
||||
encode(message: Index, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.digest.length !== 0) {
|
||||
writer.uint32(10).bytes(message.digest);
|
||||
}
|
||||
if (message.receivedTime !== 0) {
|
||||
writer.uint32(17).double(message.receivedTime);
|
||||
}
|
||||
if (message.senderTime !== 0) {
|
||||
writer.uint32(25).double(message.senderTime);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Index {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseIndex();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.digest = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.receivedTime = reader.double();
|
||||
break;
|
||||
case 3:
|
||||
message.senderTime = reader.double();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Index {
|
||||
return {
|
||||
digest: isSet(object.digest)
|
||||
? bytesFromBase64(object.digest)
|
||||
: new Uint8Array(),
|
||||
receivedTime: isSet(object.receivedTime)
|
||||
? Number(object.receivedTime)
|
||||
: 0,
|
||||
senderTime: isSet(object.senderTime) ? Number(object.senderTime) : 0,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Index): unknown {
|
||||
const obj: any = {};
|
||||
message.digest !== undefined &&
|
||||
(obj.digest = base64FromBytes(
|
||||
message.digest !== undefined ? message.digest : new Uint8Array()
|
||||
));
|
||||
message.receivedTime !== undefined &&
|
||||
(obj.receivedTime = message.receivedTime);
|
||||
message.senderTime !== undefined && (obj.senderTime = message.senderTime);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<Index>, I>>(object: I): Index {
|
||||
const message = createBaseIndex();
|
||||
message.digest = object.digest ?? new Uint8Array();
|
||||
message.receivedTime = object.receivedTime ?? 0;
|
||||
message.senderTime = object.senderTime ?? 0;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePagingInfo(): PagingInfo {
|
||||
return { pageSize: Long.UZERO, cursor: undefined, direction: 0 };
|
||||
}
|
||||
|
||||
export const PagingInfo = {
|
||||
encode(
|
||||
message: PagingInfo,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (!message.pageSize.isZero()) {
|
||||
writer.uint32(8).uint64(message.pageSize);
|
||||
}
|
||||
if (message.cursor !== undefined) {
|
||||
Index.encode(message.cursor, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.direction !== 0) {
|
||||
writer.uint32(24).int32(message.direction);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PagingInfo {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePagingInfo();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.pageSize = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.cursor = Index.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.direction = reader.int32() as any;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PagingInfo {
|
||||
return {
|
||||
pageSize: isSet(object.pageSize)
|
||||
? Long.fromString(object.pageSize)
|
||||
: Long.UZERO,
|
||||
cursor: isSet(object.cursor) ? Index.fromJSON(object.cursor) : undefined,
|
||||
direction: isSet(object.direction)
|
||||
? pagingInfo_DirectionFromJSON(object.direction)
|
||||
: 0,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PagingInfo): unknown {
|
||||
const obj: any = {};
|
||||
message.pageSize !== undefined &&
|
||||
(obj.pageSize = (message.pageSize || Long.UZERO).toString());
|
||||
message.cursor !== undefined &&
|
||||
(obj.cursor = message.cursor ? Index.toJSON(message.cursor) : undefined);
|
||||
message.direction !== undefined &&
|
||||
(obj.direction = pagingInfo_DirectionToJSON(message.direction));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<PagingInfo>, I>>(
|
||||
object: I
|
||||
): PagingInfo {
|
||||
const message = createBasePagingInfo();
|
||||
message.pageSize =
|
||||
object.pageSize !== undefined && object.pageSize !== null
|
||||
? Long.fromValue(object.pageSize)
|
||||
: Long.UZERO;
|
||||
message.cursor =
|
||||
object.cursor !== undefined && object.cursor !== null
|
||||
? Index.fromPartial(object.cursor)
|
||||
: undefined;
|
||||
message.direction = object.direction ?? 0;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseContentFilter(): ContentFilter {
|
||||
return { contentTopic: "" };
|
||||
}
|
||||
|
||||
export const ContentFilter = {
|
||||
encode(
|
||||
message: ContentFilter,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.contentTopic !== "") {
|
||||
writer.uint32(10).string(message.contentTopic);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ContentFilter {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseContentFilter();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.contentTopic = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ContentFilter {
|
||||
return {
|
||||
contentTopic: isSet(object.contentTopic)
|
||||
? String(object.contentTopic)
|
||||
: "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: ContentFilter): unknown {
|
||||
const obj: any = {};
|
||||
message.contentTopic !== undefined &&
|
||||
(obj.contentTopic = message.contentTopic);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<ContentFilter>, I>>(
|
||||
object: I
|
||||
): ContentFilter {
|
||||
const message = createBaseContentFilter();
|
||||
message.contentTopic = object.contentTopic ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseHistoryQuery(): HistoryQuery {
|
||||
return {
|
||||
pubSubTopic: undefined,
|
||||
contentFilters: [],
|
||||
pagingInfo: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export const HistoryQuery = {
|
||||
encode(
|
||||
message: HistoryQuery,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.pubSubTopic !== undefined) {
|
||||
writer.uint32(18).string(message.pubSubTopic);
|
||||
}
|
||||
for (const v of message.contentFilters) {
|
||||
ContentFilter.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.pagingInfo !== undefined) {
|
||||
PagingInfo.encode(message.pagingInfo, writer.uint32(34).fork()).ldelim();
|
||||
}
|
||||
if (message.startTime !== undefined) {
|
||||
writer.uint32(41).double(message.startTime);
|
||||
}
|
||||
if (message.endTime !== undefined) {
|
||||
writer.uint32(49).double(message.endTime);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): HistoryQuery {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseHistoryQuery();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 2:
|
||||
message.pubSubTopic = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.contentFilters.push(
|
||||
ContentFilter.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
message.pagingInfo = PagingInfo.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 5:
|
||||
message.startTime = reader.double();
|
||||
break;
|
||||
case 6:
|
||||
message.endTime = reader.double();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HistoryQuery {
|
||||
return {
|
||||
pubSubTopic: isSet(object.pubSubTopic)
|
||||
? String(object.pubSubTopic)
|
||||
: undefined,
|
||||
contentFilters: Array.isArray(object?.contentFilters)
|
||||
? object.contentFilters.map((e: any) => ContentFilter.fromJSON(e))
|
||||
: [],
|
||||
pagingInfo: isSet(object.pagingInfo)
|
||||
? PagingInfo.fromJSON(object.pagingInfo)
|
||||
: undefined,
|
||||
startTime: isSet(object.startTime) ? Number(object.startTime) : undefined,
|
||||
endTime: isSet(object.endTime) ? Number(object.endTime) : undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: HistoryQuery): unknown {
|
||||
const obj: any = {};
|
||||
message.pubSubTopic !== undefined &&
|
||||
(obj.pubSubTopic = message.pubSubTopic);
|
||||
if (message.contentFilters) {
|
||||
obj.contentFilters = message.contentFilters.map((e) =>
|
||||
e ? ContentFilter.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.contentFilters = [];
|
||||
}
|
||||
message.pagingInfo !== undefined &&
|
||||
(obj.pagingInfo = message.pagingInfo
|
||||
? PagingInfo.toJSON(message.pagingInfo)
|
||||
: undefined);
|
||||
message.startTime !== undefined && (obj.startTime = message.startTime);
|
||||
message.endTime !== undefined && (obj.endTime = message.endTime);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<HistoryQuery>, I>>(
|
||||
object: I
|
||||
): HistoryQuery {
|
||||
const message = createBaseHistoryQuery();
|
||||
message.pubSubTopic = object.pubSubTopic ?? undefined;
|
||||
message.contentFilters =
|
||||
object.contentFilters?.map((e) => ContentFilter.fromPartial(e)) || [];
|
||||
message.pagingInfo =
|
||||
object.pagingInfo !== undefined && object.pagingInfo !== null
|
||||
? PagingInfo.fromPartial(object.pagingInfo)
|
||||
: undefined;
|
||||
message.startTime = object.startTime ?? undefined;
|
||||
message.endTime = object.endTime ?? undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseHistoryResponse(): HistoryResponse {
|
||||
return { messages: [], pagingInfo: undefined, error: 0 };
|
||||
}
|
||||
|
||||
export const HistoryResponse = {
|
||||
encode(
|
||||
message: HistoryResponse,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
for (const v of message.messages) {
|
||||
WakuMessage.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.pagingInfo !== undefined) {
|
||||
PagingInfo.encode(message.pagingInfo, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.error !== 0) {
|
||||
writer.uint32(32).int32(message.error);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): HistoryResponse {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseHistoryResponse();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 2:
|
||||
message.messages.push(WakuMessage.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 3:
|
||||
message.pagingInfo = PagingInfo.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.error = reader.int32() as any;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HistoryResponse {
|
||||
return {
|
||||
messages: Array.isArray(object?.messages)
|
||||
? object.messages.map((e: any) => WakuMessage.fromJSON(e))
|
||||
: [],
|
||||
pagingInfo: isSet(object.pagingInfo)
|
||||
? PagingInfo.fromJSON(object.pagingInfo)
|
||||
: undefined,
|
||||
error: isSet(object.error)
|
||||
? historyResponse_ErrorFromJSON(object.error)
|
||||
: 0,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: HistoryResponse): unknown {
|
||||
const obj: any = {};
|
||||
if (message.messages) {
|
||||
obj.messages = message.messages.map((e) =>
|
||||
e ? WakuMessage.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.messages = [];
|
||||
}
|
||||
message.pagingInfo !== undefined &&
|
||||
(obj.pagingInfo = message.pagingInfo
|
||||
? PagingInfo.toJSON(message.pagingInfo)
|
||||
: undefined);
|
||||
message.error !== undefined &&
|
||||
(obj.error = historyResponse_ErrorToJSON(message.error));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<HistoryResponse>, I>>(
|
||||
object: I
|
||||
): HistoryResponse {
|
||||
const message = createBaseHistoryResponse();
|
||||
message.messages =
|
||||
object.messages?.map((e) => WakuMessage.fromPartial(e)) || [];
|
||||
message.pagingInfo =
|
||||
object.pagingInfo !== undefined && object.pagingInfo !== null
|
||||
? PagingInfo.fromPartial(object.pagingInfo)
|
||||
: undefined;
|
||||
message.error = object.error ?? 0;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseHistoryRPC(): HistoryRPC {
|
||||
return { requestId: "", query: undefined, response: undefined };
|
||||
}
|
||||
|
||||
export const HistoryRPC = {
|
||||
encode(
|
||||
message: HistoryRPC,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.requestId !== "") {
|
||||
writer.uint32(10).string(message.requestId);
|
||||
}
|
||||
if (message.query !== undefined) {
|
||||
HistoryQuery.encode(message.query, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.response !== undefined) {
|
||||
HistoryResponse.encode(
|
||||
message.response,
|
||||
writer.uint32(26).fork()
|
||||
).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): HistoryRPC {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseHistoryRPC();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.requestId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.query = HistoryQuery.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.response = HistoryResponse.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HistoryRPC {
|
||||
return {
|
||||
requestId: isSet(object.requestId) ? String(object.requestId) : "",
|
||||
query: isSet(object.query)
|
||||
? HistoryQuery.fromJSON(object.query)
|
||||
: undefined,
|
||||
response: isSet(object.response)
|
||||
? HistoryResponse.fromJSON(object.response)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: HistoryRPC): unknown {
|
||||
const obj: any = {};
|
||||
message.requestId !== undefined && (obj.requestId = message.requestId);
|
||||
message.query !== undefined &&
|
||||
(obj.query = message.query
|
||||
? HistoryQuery.toJSON(message.query)
|
||||
: undefined);
|
||||
message.response !== undefined &&
|
||||
(obj.response = message.response
|
||||
? HistoryResponse.toJSON(message.response)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<HistoryRPC>, I>>(
|
||||
object: I
|
||||
): HistoryRPC {
|
||||
const message = createBaseHistoryRPC();
|
||||
message.requestId = object.requestId ?? "";
|
||||
message.query =
|
||||
object.query !== undefined && object.query !== null
|
||||
? HistoryQuery.fromPartial(object.query)
|
||||
: undefined;
|
||||
message.response =
|
||||
object.response !== undefined && object.response !== null
|
||||
? HistoryResponse.fromPartial(object.response)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
declare var global: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (const byte of arr) {
|
||||
bin.push(String.fromCharCode(byte));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Long
|
||||
? string | number | Long
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
||||
Exclude<keyof I, KeysOfUnion<P>>,
|
||||
never
|
||||
>;
|
||||
|
||||
if (_m0.util.Long !== Long) {
|
||||
_m0.util.Long = Long as any;
|
||||
_m0.configure();
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
}
|
|
@ -1,741 +0,0 @@
|
|||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import { WakuMessage } from "../../../../waku/v2/message";
|
||||
|
||||
export const protobufPackage = "waku.v2.store.v2beta4";
|
||||
|
||||
export interface Index {
|
||||
digest: Uint8Array;
|
||||
receivedTime: Long;
|
||||
senderTime: Long;
|
||||
pubsubTopic: string;
|
||||
}
|
||||
|
||||
export interface PagingInfo {
|
||||
pageSize: Long;
|
||||
cursor: Index | undefined;
|
||||
direction: PagingInfo_Direction;
|
||||
}
|
||||
|
||||
export enum PagingInfo_Direction {
|
||||
DIRECTION_BACKWARD_UNSPECIFIED = 0,
|
||||
DIRECTION_FORWARD = 1,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function pagingInfo_DirectionFromJSON(
|
||||
object: any
|
||||
): PagingInfo_Direction {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "DIRECTION_BACKWARD_UNSPECIFIED":
|
||||
return PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
||||
case 1:
|
||||
case "DIRECTION_FORWARD":
|
||||
return PagingInfo_Direction.DIRECTION_FORWARD;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return PagingInfo_Direction.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function pagingInfo_DirectionToJSON(
|
||||
object: PagingInfo_Direction
|
||||
): string {
|
||||
switch (object) {
|
||||
case PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED:
|
||||
return "DIRECTION_BACKWARD_UNSPECIFIED";
|
||||
case PagingInfo_Direction.DIRECTION_FORWARD:
|
||||
return "DIRECTION_FORWARD";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContentFilter {
|
||||
contentTopic: string;
|
||||
}
|
||||
|
||||
export interface HistoryQuery {
|
||||
pubSubTopic?: string | undefined;
|
||||
contentFilters: ContentFilter[];
|
||||
pagingInfo?: PagingInfo | undefined;
|
||||
startTime?: Long | undefined;
|
||||
endTime?: Long | undefined;
|
||||
}
|
||||
|
||||
export interface HistoryResponse {
|
||||
messages: WakuMessage[];
|
||||
pagingInfo: PagingInfo | undefined;
|
||||
error: HistoryResponse_Error;
|
||||
}
|
||||
|
||||
export enum HistoryResponse_Error {
|
||||
ERROR_NONE_UNSPECIFIED = 0,
|
||||
ERROR_INVALID_CURSOR = 1,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function historyResponse_ErrorFromJSON(
|
||||
object: any
|
||||
): HistoryResponse_Error {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "ERROR_NONE_UNSPECIFIED":
|
||||
return HistoryResponse_Error.ERROR_NONE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "ERROR_INVALID_CURSOR":
|
||||
return HistoryResponse_Error.ERROR_INVALID_CURSOR;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return HistoryResponse_Error.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function historyResponse_ErrorToJSON(
|
||||
object: HistoryResponse_Error
|
||||
): string {
|
||||
switch (object) {
|
||||
case HistoryResponse_Error.ERROR_NONE_UNSPECIFIED:
|
||||
return "ERROR_NONE_UNSPECIFIED";
|
||||
case HistoryResponse_Error.ERROR_INVALID_CURSOR:
|
||||
return "ERROR_INVALID_CURSOR";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
export interface HistoryRPC {
|
||||
requestId: string;
|
||||
query: HistoryQuery | undefined;
|
||||
response: HistoryResponse | undefined;
|
||||
}
|
||||
|
||||
function createBaseIndex(): Index {
|
||||
return {
|
||||
digest: new Uint8Array(),
|
||||
receivedTime: Long.ZERO,
|
||||
senderTime: Long.ZERO,
|
||||
pubsubTopic: "",
|
||||
};
|
||||
}
|
||||
|
||||
export const Index = {
|
||||
encode(message: Index, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.digest.length !== 0) {
|
||||
writer.uint32(10).bytes(message.digest);
|
||||
}
|
||||
if (!message.receivedTime.isZero()) {
|
||||
writer.uint32(16).sint64(message.receivedTime);
|
||||
}
|
||||
if (!message.senderTime.isZero()) {
|
||||
writer.uint32(24).sint64(message.senderTime);
|
||||
}
|
||||
if (message.pubsubTopic !== "") {
|
||||
writer.uint32(34).string(message.pubsubTopic);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Index {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseIndex();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.digest = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.receivedTime = reader.sint64() as Long;
|
||||
break;
|
||||
case 3:
|
||||
message.senderTime = reader.sint64() as Long;
|
||||
break;
|
||||
case 4:
|
||||
message.pubsubTopic = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Index {
|
||||
return {
|
||||
digest: isSet(object.digest)
|
||||
? bytesFromBase64(object.digest)
|
||||
: new Uint8Array(),
|
||||
receivedTime: isSet(object.receivedTime)
|
||||
? Long.fromString(object.receivedTime)
|
||||
: Long.ZERO,
|
||||
senderTime: isSet(object.senderTime)
|
||||
? Long.fromString(object.senderTime)
|
||||
: Long.ZERO,
|
||||
pubsubTopic: isSet(object.pubsubTopic) ? String(object.pubsubTopic) : "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Index): unknown {
|
||||
const obj: any = {};
|
||||
message.digest !== undefined &&
|
||||
(obj.digest = base64FromBytes(
|
||||
message.digest !== undefined ? message.digest : new Uint8Array()
|
||||
));
|
||||
message.receivedTime !== undefined &&
|
||||
(obj.receivedTime = (message.receivedTime || Long.ZERO).toString());
|
||||
message.senderTime !== undefined &&
|
||||
(obj.senderTime = (message.senderTime || Long.ZERO).toString());
|
||||
message.pubsubTopic !== undefined &&
|
||||
(obj.pubsubTopic = message.pubsubTopic);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<Index>, I>>(object: I): Index {
|
||||
const message = createBaseIndex();
|
||||
message.digest = object.digest ?? new Uint8Array();
|
||||
message.receivedTime =
|
||||
object.receivedTime !== undefined && object.receivedTime !== null
|
||||
? Long.fromValue(object.receivedTime)
|
||||
: Long.ZERO;
|
||||
message.senderTime =
|
||||
object.senderTime !== undefined && object.senderTime !== null
|
||||
? Long.fromValue(object.senderTime)
|
||||
: Long.ZERO;
|
||||
message.pubsubTopic = object.pubsubTopic ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePagingInfo(): PagingInfo {
|
||||
return { pageSize: Long.UZERO, cursor: undefined, direction: 0 };
|
||||
}
|
||||
|
||||
export const PagingInfo = {
|
||||
encode(
|
||||
message: PagingInfo,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (!message.pageSize.isZero()) {
|
||||
writer.uint32(8).uint64(message.pageSize);
|
||||
}
|
||||
if (message.cursor !== undefined) {
|
||||
Index.encode(message.cursor, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.direction !== 0) {
|
||||
writer.uint32(24).int32(message.direction);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PagingInfo {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePagingInfo();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.pageSize = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.cursor = Index.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.direction = reader.int32() as any;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PagingInfo {
|
||||
return {
|
||||
pageSize: isSet(object.pageSize)
|
||||
? Long.fromString(object.pageSize)
|
||||
: Long.UZERO,
|
||||
cursor: isSet(object.cursor) ? Index.fromJSON(object.cursor) : undefined,
|
||||
direction: isSet(object.direction)
|
||||
? pagingInfo_DirectionFromJSON(object.direction)
|
||||
: 0,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PagingInfo): unknown {
|
||||
const obj: any = {};
|
||||
message.pageSize !== undefined &&
|
||||
(obj.pageSize = (message.pageSize || Long.UZERO).toString());
|
||||
message.cursor !== undefined &&
|
||||
(obj.cursor = message.cursor ? Index.toJSON(message.cursor) : undefined);
|
||||
message.direction !== undefined &&
|
||||
(obj.direction = pagingInfo_DirectionToJSON(message.direction));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<PagingInfo>, I>>(
|
||||
object: I
|
||||
): PagingInfo {
|
||||
const message = createBasePagingInfo();
|
||||
message.pageSize =
|
||||
object.pageSize !== undefined && object.pageSize !== null
|
||||
? Long.fromValue(object.pageSize)
|
||||
: Long.UZERO;
|
||||
message.cursor =
|
||||
object.cursor !== undefined && object.cursor !== null
|
||||
? Index.fromPartial(object.cursor)
|
||||
: undefined;
|
||||
message.direction = object.direction ?? 0;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseContentFilter(): ContentFilter {
|
||||
return { contentTopic: "" };
|
||||
}
|
||||
|
||||
export const ContentFilter = {
|
||||
encode(
|
||||
message: ContentFilter,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.contentTopic !== "") {
|
||||
writer.uint32(10).string(message.contentTopic);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ContentFilter {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseContentFilter();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.contentTopic = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ContentFilter {
|
||||
return {
|
||||
contentTopic: isSet(object.contentTopic)
|
||||
? String(object.contentTopic)
|
||||
: "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: ContentFilter): unknown {
|
||||
const obj: any = {};
|
||||
message.contentTopic !== undefined &&
|
||||
(obj.contentTopic = message.contentTopic);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<ContentFilter>, I>>(
|
||||
object: I
|
||||
): ContentFilter {
|
||||
const message = createBaseContentFilter();
|
||||
message.contentTopic = object.contentTopic ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseHistoryQuery(): HistoryQuery {
|
||||
return {
|
||||
pubSubTopic: undefined,
|
||||
contentFilters: [],
|
||||
pagingInfo: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export const HistoryQuery = {
|
||||
encode(
|
||||
message: HistoryQuery,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.pubSubTopic !== undefined) {
|
||||
writer.uint32(18).string(message.pubSubTopic);
|
||||
}
|
||||
for (const v of message.contentFilters) {
|
||||
ContentFilter.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.pagingInfo !== undefined) {
|
||||
PagingInfo.encode(message.pagingInfo, writer.uint32(34).fork()).ldelim();
|
||||
}
|
||||
if (message.startTime !== undefined) {
|
||||
writer.uint32(40).sint64(message.startTime);
|
||||
}
|
||||
if (message.endTime !== undefined) {
|
||||
writer.uint32(48).sint64(message.endTime);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): HistoryQuery {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseHistoryQuery();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 2:
|
||||
message.pubSubTopic = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.contentFilters.push(
|
||||
ContentFilter.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
message.pagingInfo = PagingInfo.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 5:
|
||||
message.startTime = reader.sint64() as Long;
|
||||
break;
|
||||
case 6:
|
||||
message.endTime = reader.sint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HistoryQuery {
|
||||
return {
|
||||
pubSubTopic: isSet(object.pubSubTopic)
|
||||
? String(object.pubSubTopic)
|
||||
: undefined,
|
||||
contentFilters: Array.isArray(object?.contentFilters)
|
||||
? object.contentFilters.map((e: any) => ContentFilter.fromJSON(e))
|
||||
: [],
|
||||
pagingInfo: isSet(object.pagingInfo)
|
||||
? PagingInfo.fromJSON(object.pagingInfo)
|
||||
: undefined,
|
||||
startTime: isSet(object.startTime)
|
||||
? Long.fromString(object.startTime)
|
||||
: undefined,
|
||||
endTime: isSet(object.endTime)
|
||||
? Long.fromString(object.endTime)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: HistoryQuery): unknown {
|
||||
const obj: any = {};
|
||||
message.pubSubTopic !== undefined &&
|
||||
(obj.pubSubTopic = message.pubSubTopic);
|
||||
if (message.contentFilters) {
|
||||
obj.contentFilters = message.contentFilters.map((e) =>
|
||||
e ? ContentFilter.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.contentFilters = [];
|
||||
}
|
||||
message.pagingInfo !== undefined &&
|
||||
(obj.pagingInfo = message.pagingInfo
|
||||
? PagingInfo.toJSON(message.pagingInfo)
|
||||
: undefined);
|
||||
message.startTime !== undefined &&
|
||||
(obj.startTime = (message.startTime || undefined).toString());
|
||||
message.endTime !== undefined &&
|
||||
(obj.endTime = (message.endTime || undefined).toString());
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<HistoryQuery>, I>>(
|
||||
object: I
|
||||
): HistoryQuery {
|
||||
const message = createBaseHistoryQuery();
|
||||
message.pubSubTopic = object.pubSubTopic ?? undefined;
|
||||
message.contentFilters =
|
||||
object.contentFilters?.map((e) => ContentFilter.fromPartial(e)) || [];
|
||||
message.pagingInfo =
|
||||
object.pagingInfo !== undefined && object.pagingInfo !== null
|
||||
? PagingInfo.fromPartial(object.pagingInfo)
|
||||
: undefined;
|
||||
message.startTime =
|
||||
object.startTime !== undefined && object.startTime !== null
|
||||
? Long.fromValue(object.startTime)
|
||||
: undefined;
|
||||
message.endTime =
|
||||
object.endTime !== undefined && object.endTime !== null
|
||||
? Long.fromValue(object.endTime)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseHistoryResponse(): HistoryResponse {
|
||||
return { messages: [], pagingInfo: undefined, error: 0 };
|
||||
}
|
||||
|
||||
export const HistoryResponse = {
|
||||
encode(
|
||||
message: HistoryResponse,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
for (const v of message.messages) {
|
||||
WakuMessage.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.pagingInfo !== undefined) {
|
||||
PagingInfo.encode(message.pagingInfo, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.error !== 0) {
|
||||
writer.uint32(32).int32(message.error);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): HistoryResponse {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseHistoryResponse();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 2:
|
||||
message.messages.push(WakuMessage.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 3:
|
||||
message.pagingInfo = PagingInfo.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.error = reader.int32() as any;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HistoryResponse {
|
||||
return {
|
||||
messages: Array.isArray(object?.messages)
|
||||
? object.messages.map((e: any) => WakuMessage.fromJSON(e))
|
||||
: [],
|
||||
pagingInfo: isSet(object.pagingInfo)
|
||||
? PagingInfo.fromJSON(object.pagingInfo)
|
||||
: undefined,
|
||||
error: isSet(object.error)
|
||||
? historyResponse_ErrorFromJSON(object.error)
|
||||
: 0,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: HistoryResponse): unknown {
|
||||
const obj: any = {};
|
||||
if (message.messages) {
|
||||
obj.messages = message.messages.map((e) =>
|
||||
e ? WakuMessage.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.messages = [];
|
||||
}
|
||||
message.pagingInfo !== undefined &&
|
||||
(obj.pagingInfo = message.pagingInfo
|
||||
? PagingInfo.toJSON(message.pagingInfo)
|
||||
: undefined);
|
||||
message.error !== undefined &&
|
||||
(obj.error = historyResponse_ErrorToJSON(message.error));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<HistoryResponse>, I>>(
|
||||
object: I
|
||||
): HistoryResponse {
|
||||
const message = createBaseHistoryResponse();
|
||||
message.messages =
|
||||
object.messages?.map((e) => WakuMessage.fromPartial(e)) || [];
|
||||
message.pagingInfo =
|
||||
object.pagingInfo !== undefined && object.pagingInfo !== null
|
||||
? PagingInfo.fromPartial(object.pagingInfo)
|
||||
: undefined;
|
||||
message.error = object.error ?? 0;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseHistoryRPC(): HistoryRPC {
|
||||
return { requestId: "", query: undefined, response: undefined };
|
||||
}
|
||||
|
||||
export const HistoryRPC = {
|
||||
encode(
|
||||
message: HistoryRPC,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.requestId !== "") {
|
||||
writer.uint32(10).string(message.requestId);
|
||||
}
|
||||
if (message.query !== undefined) {
|
||||
HistoryQuery.encode(message.query, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.response !== undefined) {
|
||||
HistoryResponse.encode(
|
||||
message.response,
|
||||
writer.uint32(26).fork()
|
||||
).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): HistoryRPC {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseHistoryRPC();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.requestId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.query = HistoryQuery.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.response = HistoryResponse.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HistoryRPC {
|
||||
return {
|
||||
requestId: isSet(object.requestId) ? String(object.requestId) : "",
|
||||
query: isSet(object.query)
|
||||
? HistoryQuery.fromJSON(object.query)
|
||||
: undefined,
|
||||
response: isSet(object.response)
|
||||
? HistoryResponse.fromJSON(object.response)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: HistoryRPC): unknown {
|
||||
const obj: any = {};
|
||||
message.requestId !== undefined && (obj.requestId = message.requestId);
|
||||
message.query !== undefined &&
|
||||
(obj.query = message.query
|
||||
? HistoryQuery.toJSON(message.query)
|
||||
: undefined);
|
||||
message.response !== undefined &&
|
||||
(obj.response = message.response
|
||||
? HistoryResponse.toJSON(message.response)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<HistoryRPC>, I>>(
|
||||
object: I
|
||||
): HistoryRPC {
|
||||
const message = createBaseHistoryRPC();
|
||||
message.requestId = object.requestId ?? "";
|
||||
message.query =
|
||||
object.query !== undefined && object.query !== null
|
||||
? HistoryQuery.fromPartial(object.query)
|
||||
: undefined;
|
||||
message.response =
|
||||
object.response !== undefined && object.response !== null
|
||||
? HistoryResponse.fromPartial(object.response)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
declare var global: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (const byte of arr) {
|
||||
bin.push(String.fromCharCode(byte));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Long
|
||||
? string | number | Long
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
||||
Exclude<keyof I, KeysOfUnion<P>>,
|
||||
never
|
||||
>;
|
||||
|
||||
if (_m0.util.Long !== Long) {
|
||||
_m0.util.Long = Long as any;
|
||||
_m0.configure();
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
}
|
|
@ -14,7 +14,7 @@ import portfinder from "portfinder";
|
|||
import { DefaultPubSubTopic } from "../lib/constants";
|
||||
import { hexToBytes } from "../lib/utils";
|
||||
import { WakuMessage } from "../lib/waku_message";
|
||||
import * as proto from "../proto/waku/v2/message";
|
||||
import * as proto from "../proto/message";
|
||||
|
||||
import { existsAsync, mkdirAsync, openAsync } from "./async_fs";
|
||||
import waitForLine from "./log_file";
|
||||
|
@ -88,7 +88,7 @@ export class Nwaku {
|
|||
|
||||
let timestamp;
|
||||
if (message.proto.timestamp) {
|
||||
timestamp = message.proto.timestamp.toNumber();
|
||||
timestamp = Number.parseInt(message.proto.timestamp.toString(10));
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue