mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-07 16:23:09 +00:00
Merge #41
41: Update to latest waku store r=D4nte a=D4nte Resolves #42 Co-authored-by: Franck Royer <franck@royer.one>
This commit is contained in:
commit
16251f6979
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -77,6 +77,11 @@ jobs:
|
|||||||
- name: build
|
- name: build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Check no proto files changed
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
[ $(git status --short --ignore-submodules|wc -l) -eq 0 ]
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: npm run test
|
run: npm run test
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ You can track progress on the [project board](https://github.com/status-im/js-wa
|
|||||||
|[10/WAKU2](https://rfc.vac.dev/spec/10)|🚧|
|
|[10/WAKU2](https://rfc.vac.dev/spec/10)|🚧|
|
||||||
|[11/WAKU2-RELAY](https://rfc.vac.dev/spec/11)|✔|
|
|[11/WAKU2-RELAY](https://rfc.vac.dev/spec/11)|✔|
|
||||||
|[12/WAKU2-FILTER](https://rfc.vac.dev/spec/12)||
|
|[12/WAKU2-FILTER](https://rfc.vac.dev/spec/12)||
|
||||||
|[13/WAKU2-STORE](https://rfc.vac.dev/spec/13)|🚧|
|
|[13/WAKU2-STORE](https://rfc.vac.dev/spec/13)|✔ (querying node only)|
|
||||||
|[14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14)|✔|
|
|[14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14)|✔|
|
||||||
|[15/WAKU2-BRIDGE](https://rfc.vac.dev/spec/15)||
|
|[15/WAKU2-BRIDGE](https://rfc.vac.dev/spec/15)||
|
||||||
|[16/WAKU2-RPC](https://rfc.vac.dev/spec/16)|⛔|
|
|[16/WAKU2-RPC](https://rfc.vac.dev/spec/16)|⛔|
|
||||||
|
|||||||
2
nim-waku
2
nim-waku
@ -1 +1 @@
|
|||||||
Subproject commit 286482ea32401952ff01b80ad7cc183cb9336c06
|
Subproject commit fb2ea06a4fdfaee91aa081be2592eb79349ed6c2
|
||||||
@ -9,19 +9,22 @@ message Index {
|
|||||||
double received_time = 2;
|
double received_time = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Direction {
|
|
||||||
DIRECTION_BACKWARD_UNSPECIFIED = 0;
|
|
||||||
DIRECTION_FORWARD = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PagingInfo {
|
message PagingInfo {
|
||||||
uint64 page_size = 1;
|
uint64 page_size = 1;
|
||||||
Index cursor = 2;
|
Index cursor = 2;
|
||||||
|
enum Direction {
|
||||||
|
DIRECTION_BACKWARD_UNSPECIFIED = 0;
|
||||||
|
DIRECTION_FORWARD = 1;
|
||||||
|
}
|
||||||
Direction direction = 3;
|
Direction direction = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ContentFilter {
|
||||||
|
string content_topic = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message HistoryQuery {
|
message HistoryQuery {
|
||||||
repeated string topics = 2;
|
repeated ContentFilter content_filters = 2;
|
||||||
optional PagingInfo paging_info = 3;
|
optional PagingInfo paging_info = 3;
|
||||||
optional double start_time = 4;
|
optional double start_time = 4;
|
||||||
optional double end_time = 5;
|
optional double end_time = 5;
|
||||||
|
|||||||
@ -8,17 +8,27 @@ export class HistoryRPC {
|
|||||||
public constructor(public proto: proto.HistoryRPC) {}
|
public constructor(public proto: proto.HistoryRPC) {}
|
||||||
|
|
||||||
static createQuery(
|
static createQuery(
|
||||||
topics: string[] = [DEFAULT_CONTENT_TOPIC],
|
contentTopics: string[] = [DEFAULT_CONTENT_TOPIC],
|
||||||
cursor?: proto.Index
|
cursor?: proto.Index
|
||||||
): HistoryRPC {
|
): HistoryRPC {
|
||||||
const pagingInfo = {
|
const pagingInfo = {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
cursor,
|
cursor,
|
||||||
direction: proto.Direction.DIRECTION_FORWARD,
|
direction: proto.PagingInfo_Direction.DIRECTION_FORWARD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const contentFilters = contentTopics.map((contentTopic) => {
|
||||||
|
return { contentTopic };
|
||||||
|
});
|
||||||
|
|
||||||
return new HistoryRPC({
|
return new HistoryRPC({
|
||||||
requestId: uuid(),
|
requestId: uuid(),
|
||||||
query: { topics, pagingInfo, startTime: undefined, endTime: undefined },
|
query: {
|
||||||
|
contentFilters,
|
||||||
|
pagingInfo,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
},
|
||||||
response: undefined,
|
response: undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,38 +5,6 @@ import _m0 from 'protobufjs/minimal';
|
|||||||
|
|
||||||
export const protobufPackage = 'waku.v2';
|
export const protobufPackage = 'waku.v2';
|
||||||
|
|
||||||
export enum Direction {
|
|
||||||
DIRECTION_BACKWARD_UNSPECIFIED = 0,
|
|
||||||
DIRECTION_FORWARD = 1,
|
|
||||||
UNRECOGNIZED = -1,
|
|
||||||
}
|
|
||||||
|
|
||||||
export function directionFromJSON(object: any): Direction {
|
|
||||||
switch (object) {
|
|
||||||
case 0:
|
|
||||||
case 'DIRECTION_BACKWARD_UNSPECIFIED':
|
|
||||||
return Direction.DIRECTION_BACKWARD_UNSPECIFIED;
|
|
||||||
case 1:
|
|
||||||
case 'DIRECTION_FORWARD':
|
|
||||||
return Direction.DIRECTION_FORWARD;
|
|
||||||
case -1:
|
|
||||||
case 'UNRECOGNIZED':
|
|
||||||
default:
|
|
||||||
return Direction.UNRECOGNIZED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function directionToJSON(object: Direction): string {
|
|
||||||
switch (object) {
|
|
||||||
case Direction.DIRECTION_BACKWARD_UNSPECIFIED:
|
|
||||||
return 'DIRECTION_BACKWARD_UNSPECIFIED';
|
|
||||||
case Direction.DIRECTION_FORWARD:
|
|
||||||
return 'DIRECTION_FORWARD';
|
|
||||||
default:
|
|
||||||
return 'UNKNOWN';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Index {
|
export interface Index {
|
||||||
digest: Uint8Array;
|
digest: Uint8Array;
|
||||||
receivedTime: number;
|
receivedTime: number;
|
||||||
@ -45,11 +13,51 @@ export interface Index {
|
|||||||
export interface PagingInfo {
|
export interface PagingInfo {
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
cursor: Index | undefined;
|
cursor: Index | undefined;
|
||||||
direction: Direction;
|
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 {
|
export interface HistoryQuery {
|
||||||
topics: string[];
|
contentFilters: ContentFilter[];
|
||||||
pagingInfo?: PagingInfo | undefined;
|
pagingInfo?: PagingInfo | undefined;
|
||||||
startTime?: number | undefined;
|
startTime?: number | undefined;
|
||||||
endTime?: number | undefined;
|
endTime?: number | undefined;
|
||||||
@ -196,7 +204,7 @@ export const PagingInfo = {
|
|||||||
message.cursor = undefined;
|
message.cursor = undefined;
|
||||||
}
|
}
|
||||||
if (object.direction !== undefined && object.direction !== null) {
|
if (object.direction !== undefined && object.direction !== null) {
|
||||||
message.direction = directionFromJSON(object.direction);
|
message.direction = pagingInfo_DirectionFromJSON(object.direction);
|
||||||
} else {
|
} else {
|
||||||
message.direction = 0;
|
message.direction = 0;
|
||||||
}
|
}
|
||||||
@ -209,7 +217,7 @@ export const PagingInfo = {
|
|||||||
message.cursor !== undefined &&
|
message.cursor !== undefined &&
|
||||||
(obj.cursor = message.cursor ? Index.toJSON(message.cursor) : undefined);
|
(obj.cursor = message.cursor ? Index.toJSON(message.cursor) : undefined);
|
||||||
message.direction !== undefined &&
|
message.direction !== undefined &&
|
||||||
(obj.direction = directionToJSON(message.direction));
|
(obj.direction = pagingInfo_DirectionToJSON(message.direction));
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -234,15 +242,74 @@ export const PagingInfo = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseHistoryQuery: object = { topics: '' };
|
const baseContentFilter: object = { 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 Uint8Array ? new _m0.Reader(input) : input;
|
||||||
|
let end = length === undefined ? reader.len : reader.pos + length;
|
||||||
|
const message = { ...baseContentFilter } as 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): ContentFilter {
|
||||||
|
const message = { ...baseContentFilter } as ContentFilter;
|
||||||
|
if (object.contentTopic !== undefined && object.contentTopic !== null) {
|
||||||
|
message.contentTopic = String(object.contentTopic);
|
||||||
|
} else {
|
||||||
|
message.contentTopic = '';
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
},
|
||||||
|
|
||||||
|
toJSON(message: ContentFilter): unknown {
|
||||||
|
const obj: any = {};
|
||||||
|
message.contentTopic !== undefined &&
|
||||||
|
(obj.contentTopic = message.contentTopic);
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
|
||||||
|
fromPartial(object: DeepPartial<ContentFilter>): ContentFilter {
|
||||||
|
const message = { ...baseContentFilter } as ContentFilter;
|
||||||
|
if (object.contentTopic !== undefined && object.contentTopic !== null) {
|
||||||
|
message.contentTopic = object.contentTopic;
|
||||||
|
} else {
|
||||||
|
message.contentTopic = '';
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const baseHistoryQuery: object = {};
|
||||||
|
|
||||||
export const HistoryQuery = {
|
export const HistoryQuery = {
|
||||||
encode(
|
encode(
|
||||||
message: HistoryQuery,
|
message: HistoryQuery,
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
writer: _m0.Writer = _m0.Writer.create()
|
||||||
): _m0.Writer {
|
): _m0.Writer {
|
||||||
for (const v of message.topics) {
|
for (const v of message.contentFilters) {
|
||||||
writer.uint32(18).string(v!);
|
ContentFilter.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.pagingInfo !== undefined) {
|
if (message.pagingInfo !== undefined) {
|
||||||
PagingInfo.encode(message.pagingInfo, writer.uint32(26).fork()).ldelim();
|
PagingInfo.encode(message.pagingInfo, writer.uint32(26).fork()).ldelim();
|
||||||
@ -260,12 +327,14 @@ export const HistoryQuery = {
|
|||||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
let end = length === undefined ? reader.len : reader.pos + length;
|
||||||
const message = { ...baseHistoryQuery } as HistoryQuery;
|
const message = { ...baseHistoryQuery } as HistoryQuery;
|
||||||
message.topics = [];
|
message.contentFilters = [];
|
||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 2:
|
case 2:
|
||||||
message.topics.push(reader.string());
|
message.contentFilters.push(
|
||||||
|
ContentFilter.decode(reader, reader.uint32())
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
message.pagingInfo = PagingInfo.decode(reader, reader.uint32());
|
message.pagingInfo = PagingInfo.decode(reader, reader.uint32());
|
||||||
@ -286,10 +355,10 @@ export const HistoryQuery = {
|
|||||||
|
|
||||||
fromJSON(object: any): HistoryQuery {
|
fromJSON(object: any): HistoryQuery {
|
||||||
const message = { ...baseHistoryQuery } as HistoryQuery;
|
const message = { ...baseHistoryQuery } as HistoryQuery;
|
||||||
message.topics = [];
|
message.contentFilters = [];
|
||||||
if (object.topics !== undefined && object.topics !== null) {
|
if (object.contentFilters !== undefined && object.contentFilters !== null) {
|
||||||
for (const e of object.topics) {
|
for (const e of object.contentFilters) {
|
||||||
message.topics.push(String(e));
|
message.contentFilters.push(ContentFilter.fromJSON(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (object.pagingInfo !== undefined && object.pagingInfo !== null) {
|
if (object.pagingInfo !== undefined && object.pagingInfo !== null) {
|
||||||
@ -312,10 +381,12 @@ export const HistoryQuery = {
|
|||||||
|
|
||||||
toJSON(message: HistoryQuery): unknown {
|
toJSON(message: HistoryQuery): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
if (message.topics) {
|
if (message.contentFilters) {
|
||||||
obj.topics = message.topics.map((e) => e);
|
obj.contentFilters = message.contentFilters.map((e) =>
|
||||||
|
e ? ContentFilter.toJSON(e) : undefined
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
obj.topics = [];
|
obj.contentFilters = [];
|
||||||
}
|
}
|
||||||
message.pagingInfo !== undefined &&
|
message.pagingInfo !== undefined &&
|
||||||
(obj.pagingInfo = message.pagingInfo
|
(obj.pagingInfo = message.pagingInfo
|
||||||
@ -328,10 +399,10 @@ export const HistoryQuery = {
|
|||||||
|
|
||||||
fromPartial(object: DeepPartial<HistoryQuery>): HistoryQuery {
|
fromPartial(object: DeepPartial<HistoryQuery>): HistoryQuery {
|
||||||
const message = { ...baseHistoryQuery } as HistoryQuery;
|
const message = { ...baseHistoryQuery } as HistoryQuery;
|
||||||
message.topics = [];
|
message.contentFilters = [];
|
||||||
if (object.topics !== undefined && object.topics !== null) {
|
if (object.contentFilters !== undefined && object.contentFilters !== null) {
|
||||||
for (const e of object.topics) {
|
for (const e of object.contentFilters) {
|
||||||
message.topics.push(e);
|
message.contentFilters.push(ContentFilter.fromPartial(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (object.pagingInfo !== undefined && object.pagingInfo !== null) {
|
if (object.pagingInfo !== undefined && object.pagingInfo !== null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user