mirror of https://github.com/waku-org/js-waku.git
Merge pull request #971 from waku-org/feat/ratelimitproof
This commit is contained in:
commit
5bab85f93f
|
@ -52,6 +52,7 @@
|
|||
"libp",
|
||||
"lightpush",
|
||||
"livechat",
|
||||
"Merkle",
|
||||
"mkdir",
|
||||
"multiaddr",
|
||||
"multiaddresses",
|
||||
|
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- `RateLimitProof` field in Waku Message protobuf for RLN.
|
||||
|
||||
## [0.29.0] - 2022-09-21
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -51,17 +51,28 @@ export interface WakuFull extends Waku {
|
|||
lightPush: WakuLightPush;
|
||||
}
|
||||
|
||||
export interface RateLimitProof {
|
||||
proof: Uint8Array;
|
||||
merkleRoot: Uint8Array;
|
||||
epoch: Uint8Array;
|
||||
shareX: Uint8Array;
|
||||
shareY: Uint8Array;
|
||||
nullifier: Uint8Array;
|
||||
}
|
||||
|
||||
export interface ProtoMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestamp?: bigint;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
timestamp?: Date;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export interface Encoder {
|
||||
|
|
|
@ -303,12 +303,184 @@ export namespace FilterRPC {
|
|||
};
|
||||
}
|
||||
|
||||
export interface RateLimitProof {
|
||||
proof: Uint8Array;
|
||||
merkleRoot: Uint8Array;
|
||||
epoch: Uint8Array;
|
||||
shareX: Uint8Array;
|
||||
shareY: Uint8Array;
|
||||
nullifier: Uint8Array;
|
||||
}
|
||||
|
||||
export namespace RateLimitProof {
|
||||
let _codec: Codec<RateLimitProof>;
|
||||
|
||||
export const codec = (): Codec<RateLimitProof> => {
|
||||
if (_codec == null) {
|
||||
_codec = message<RateLimitProof>(
|
||||
(obj, writer, opts = {}) => {
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.fork();
|
||||
}
|
||||
|
||||
if (obj.proof != null) {
|
||||
writer.uint32(10);
|
||||
writer.bytes(obj.proof);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "proof" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot != null) {
|
||||
writer.uint32(18);
|
||||
writer.bytes(obj.merkleRoot);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "merkleRoot" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch != null) {
|
||||
writer.uint32(26);
|
||||
writer.bytes(obj.epoch);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "epoch" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX != null) {
|
||||
writer.uint32(34);
|
||||
writer.bytes(obj.shareX);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareX" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY != null) {
|
||||
writer.uint32(42);
|
||||
writer.bytes(obj.shareY);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareY" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier != null) {
|
||||
writer.uint32(50);
|
||||
writer.bytes(obj.nullifier);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "nullifier" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
},
|
||||
(reader, length) => {
|
||||
const obj: any = {
|
||||
proof: new Uint8Array(0),
|
||||
merkleRoot: new Uint8Array(0),
|
||||
epoch: new Uint8Array(0),
|
||||
shareX: new Uint8Array(0),
|
||||
shareY: new Uint8Array(0),
|
||||
nullifier: new Uint8Array(0),
|
||||
};
|
||||
|
||||
const end = length == null ? reader.len : reader.pos + length;
|
||||
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
obj.proof = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
obj.merkleRoot = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
obj.epoch = reader.bytes();
|
||||
break;
|
||||
case 4:
|
||||
obj.shareX = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
obj.shareY = reader.bytes();
|
||||
break;
|
||||
case 6:
|
||||
obj.nullifier = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.proof == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "proof" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "merkleRoot" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "epoch" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareX" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareY" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "nullifier" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return _codec;
|
||||
};
|
||||
|
||||
export const encode = (obj: RateLimitProof): Uint8Array => {
|
||||
return encodeMessage(obj, RateLimitProof.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
|
||||
return decodeMessage(buf, RateLimitProof.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
|
@ -347,6 +519,11 @@ export namespace WakuMessage {
|
|||
writer.sint64(obj.timestamp);
|
||||
}
|
||||
|
||||
if (obj.rateLimitProof != null) {
|
||||
writer.uint32(170);
|
||||
RateLimitProof.codec().encode(obj.rateLimitProof, writer);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
|
@ -375,6 +552,12 @@ export namespace WakuMessage {
|
|||
case 10:
|
||||
obj.timestamp = reader.sint64();
|
||||
break;
|
||||
case 21:
|
||||
obj.rateLimitProof = RateLimitProof.codec().decode(
|
||||
reader,
|
||||
reader.uint32()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
|
|
|
@ -227,12 +227,184 @@ export namespace PushRPC {
|
|||
};
|
||||
}
|
||||
|
||||
export interface RateLimitProof {
|
||||
proof: Uint8Array;
|
||||
merkleRoot: Uint8Array;
|
||||
epoch: Uint8Array;
|
||||
shareX: Uint8Array;
|
||||
shareY: Uint8Array;
|
||||
nullifier: Uint8Array;
|
||||
}
|
||||
|
||||
export namespace RateLimitProof {
|
||||
let _codec: Codec<RateLimitProof>;
|
||||
|
||||
export const codec = (): Codec<RateLimitProof> => {
|
||||
if (_codec == null) {
|
||||
_codec = message<RateLimitProof>(
|
||||
(obj, writer, opts = {}) => {
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.fork();
|
||||
}
|
||||
|
||||
if (obj.proof != null) {
|
||||
writer.uint32(10);
|
||||
writer.bytes(obj.proof);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "proof" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot != null) {
|
||||
writer.uint32(18);
|
||||
writer.bytes(obj.merkleRoot);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "merkleRoot" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch != null) {
|
||||
writer.uint32(26);
|
||||
writer.bytes(obj.epoch);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "epoch" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX != null) {
|
||||
writer.uint32(34);
|
||||
writer.bytes(obj.shareX);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareX" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY != null) {
|
||||
writer.uint32(42);
|
||||
writer.bytes(obj.shareY);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareY" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier != null) {
|
||||
writer.uint32(50);
|
||||
writer.bytes(obj.nullifier);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "nullifier" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
},
|
||||
(reader, length) => {
|
||||
const obj: any = {
|
||||
proof: new Uint8Array(0),
|
||||
merkleRoot: new Uint8Array(0),
|
||||
epoch: new Uint8Array(0),
|
||||
shareX: new Uint8Array(0),
|
||||
shareY: new Uint8Array(0),
|
||||
nullifier: new Uint8Array(0),
|
||||
};
|
||||
|
||||
const end = length == null ? reader.len : reader.pos + length;
|
||||
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
obj.proof = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
obj.merkleRoot = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
obj.epoch = reader.bytes();
|
||||
break;
|
||||
case 4:
|
||||
obj.shareX = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
obj.shareY = reader.bytes();
|
||||
break;
|
||||
case 6:
|
||||
obj.nullifier = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.proof == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "proof" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "merkleRoot" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "epoch" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareX" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareY" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "nullifier" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return _codec;
|
||||
};
|
||||
|
||||
export const encode = (obj: RateLimitProof): Uint8Array => {
|
||||
return encodeMessage(obj, RateLimitProof.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
|
||||
return decodeMessage(buf, RateLimitProof.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
|
@ -271,6 +443,11 @@ export namespace WakuMessage {
|
|||
writer.sint64(obj.timestamp);
|
||||
}
|
||||
|
||||
if (obj.rateLimitProof != null) {
|
||||
writer.uint32(170);
|
||||
RateLimitProof.codec().encode(obj.rateLimitProof, writer);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
|
@ -299,6 +476,12 @@ export namespace WakuMessage {
|
|||
case 10:
|
||||
obj.timestamp = reader.sint64();
|
||||
break;
|
||||
case 21:
|
||||
obj.rateLimitProof = RateLimitProof.codec().decode(
|
||||
reader,
|
||||
reader.uint32()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message RateLimitProof {
|
||||
bytes proof = 1;
|
||||
bytes merkle_root = 2;
|
||||
bytes epoch = 3;
|
||||
bytes share_x = 4;
|
||||
bytes share_y = 5;
|
||||
bytes nullifier = 6;
|
||||
}
|
||||
|
||||
message WakuMessage {
|
||||
optional bytes payload = 1;
|
||||
optional string content_topic = 2;
|
||||
optional uint32 version = 3;
|
||||
optional double timestamp_deprecated = 4;
|
||||
optional sint64 timestamp = 10;
|
||||
optional RateLimitProof rate_limit_proof = 21;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,184 @@ import { encodeMessage, decodeMessage, message } from "protons-runtime";
|
|||
import type { Uint8ArrayList } from "uint8arraylist";
|
||||
import type { Codec } from "protons-runtime";
|
||||
|
||||
export interface RateLimitProof {
|
||||
proof: Uint8Array;
|
||||
merkleRoot: Uint8Array;
|
||||
epoch: Uint8Array;
|
||||
shareX: Uint8Array;
|
||||
shareY: Uint8Array;
|
||||
nullifier: Uint8Array;
|
||||
}
|
||||
|
||||
export namespace RateLimitProof {
|
||||
let _codec: Codec<RateLimitProof>;
|
||||
|
||||
export const codec = (): Codec<RateLimitProof> => {
|
||||
if (_codec == null) {
|
||||
_codec = message<RateLimitProof>(
|
||||
(obj, writer, opts = {}) => {
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.fork();
|
||||
}
|
||||
|
||||
if (obj.proof != null) {
|
||||
writer.uint32(10);
|
||||
writer.bytes(obj.proof);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "proof" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot != null) {
|
||||
writer.uint32(18);
|
||||
writer.bytes(obj.merkleRoot);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "merkleRoot" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch != null) {
|
||||
writer.uint32(26);
|
||||
writer.bytes(obj.epoch);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "epoch" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX != null) {
|
||||
writer.uint32(34);
|
||||
writer.bytes(obj.shareX);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareX" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY != null) {
|
||||
writer.uint32(42);
|
||||
writer.bytes(obj.shareY);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareY" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier != null) {
|
||||
writer.uint32(50);
|
||||
writer.bytes(obj.nullifier);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "nullifier" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
},
|
||||
(reader, length) => {
|
||||
const obj: any = {
|
||||
proof: new Uint8Array(0),
|
||||
merkleRoot: new Uint8Array(0),
|
||||
epoch: new Uint8Array(0),
|
||||
shareX: new Uint8Array(0),
|
||||
shareY: new Uint8Array(0),
|
||||
nullifier: new Uint8Array(0),
|
||||
};
|
||||
|
||||
const end = length == null ? reader.len : reader.pos + length;
|
||||
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
obj.proof = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
obj.merkleRoot = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
obj.epoch = reader.bytes();
|
||||
break;
|
||||
case 4:
|
||||
obj.shareX = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
obj.shareY = reader.bytes();
|
||||
break;
|
||||
case 6:
|
||||
obj.nullifier = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.proof == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "proof" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "merkleRoot" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "epoch" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareX" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareY" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "nullifier" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return _codec;
|
||||
};
|
||||
|
||||
export const encode = (obj: RateLimitProof): Uint8Array => {
|
||||
return encodeMessage(obj, RateLimitProof.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
|
||||
return decodeMessage(buf, RateLimitProof.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
|
@ -49,6 +221,11 @@ export namespace WakuMessage {
|
|||
writer.sint64(obj.timestamp);
|
||||
}
|
||||
|
||||
if (obj.rateLimitProof != null) {
|
||||
writer.uint32(170);
|
||||
RateLimitProof.codec().encode(obj.rateLimitProof, writer);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
|
@ -77,6 +254,12 @@ export namespace WakuMessage {
|
|||
case 10:
|
||||
obj.timestamp = reader.sint64();
|
||||
break;
|
||||
case 21:
|
||||
obj.rateLimitProof = RateLimitProof.codec().decode(
|
||||
reader,
|
||||
reader.uint32()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
|
|
|
@ -536,12 +536,184 @@ export namespace HistoryRPC {
|
|||
};
|
||||
}
|
||||
|
||||
export interface RateLimitProof {
|
||||
proof: Uint8Array;
|
||||
merkleRoot: Uint8Array;
|
||||
epoch: Uint8Array;
|
||||
shareX: Uint8Array;
|
||||
shareY: Uint8Array;
|
||||
nullifier: Uint8Array;
|
||||
}
|
||||
|
||||
export namespace RateLimitProof {
|
||||
let _codec: Codec<RateLimitProof>;
|
||||
|
||||
export const codec = (): Codec<RateLimitProof> => {
|
||||
if (_codec == null) {
|
||||
_codec = message<RateLimitProof>(
|
||||
(obj, writer, opts = {}) => {
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.fork();
|
||||
}
|
||||
|
||||
if (obj.proof != null) {
|
||||
writer.uint32(10);
|
||||
writer.bytes(obj.proof);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "proof" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot != null) {
|
||||
writer.uint32(18);
|
||||
writer.bytes(obj.merkleRoot);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "merkleRoot" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch != null) {
|
||||
writer.uint32(26);
|
||||
writer.bytes(obj.epoch);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "epoch" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX != null) {
|
||||
writer.uint32(34);
|
||||
writer.bytes(obj.shareX);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareX" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY != null) {
|
||||
writer.uint32(42);
|
||||
writer.bytes(obj.shareY);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareY" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier != null) {
|
||||
writer.uint32(50);
|
||||
writer.bytes(obj.nullifier);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "nullifier" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
},
|
||||
(reader, length) => {
|
||||
const obj: any = {
|
||||
proof: new Uint8Array(0),
|
||||
merkleRoot: new Uint8Array(0),
|
||||
epoch: new Uint8Array(0),
|
||||
shareX: new Uint8Array(0),
|
||||
shareY: new Uint8Array(0),
|
||||
nullifier: new Uint8Array(0),
|
||||
};
|
||||
|
||||
const end = length == null ? reader.len : reader.pos + length;
|
||||
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
obj.proof = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
obj.merkleRoot = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
obj.epoch = reader.bytes();
|
||||
break;
|
||||
case 4:
|
||||
obj.shareX = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
obj.shareY = reader.bytes();
|
||||
break;
|
||||
case 6:
|
||||
obj.nullifier = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.proof == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "proof" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "merkleRoot" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "epoch" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareX" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareY" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "nullifier" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return _codec;
|
||||
};
|
||||
|
||||
export const encode = (obj: RateLimitProof): Uint8Array => {
|
||||
return encodeMessage(obj, RateLimitProof.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
|
||||
return decodeMessage(buf, RateLimitProof.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
|
@ -580,6 +752,11 @@ export namespace WakuMessage {
|
|||
writer.sint64(obj.timestamp);
|
||||
}
|
||||
|
||||
if (obj.rateLimitProof != null) {
|
||||
writer.uint32(170);
|
||||
RateLimitProof.codec().encode(obj.rateLimitProof, writer);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
|
@ -608,6 +785,12 @@ export namespace WakuMessage {
|
|||
case 10:
|
||||
obj.timestamp = reader.sint64();
|
||||
break;
|
||||
case 21:
|
||||
obj.rateLimitProof = RateLimitProof.codec().decode(
|
||||
reader,
|
||||
reader.uint32()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
|
|
|
@ -545,12 +545,184 @@ export namespace HistoryRPC {
|
|||
};
|
||||
}
|
||||
|
||||
export interface RateLimitProof {
|
||||
proof: Uint8Array;
|
||||
merkleRoot: Uint8Array;
|
||||
epoch: Uint8Array;
|
||||
shareX: Uint8Array;
|
||||
shareY: Uint8Array;
|
||||
nullifier: Uint8Array;
|
||||
}
|
||||
|
||||
export namespace RateLimitProof {
|
||||
let _codec: Codec<RateLimitProof>;
|
||||
|
||||
export const codec = (): Codec<RateLimitProof> => {
|
||||
if (_codec == null) {
|
||||
_codec = message<RateLimitProof>(
|
||||
(obj, writer, opts = {}) => {
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.fork();
|
||||
}
|
||||
|
||||
if (obj.proof != null) {
|
||||
writer.uint32(10);
|
||||
writer.bytes(obj.proof);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "proof" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot != null) {
|
||||
writer.uint32(18);
|
||||
writer.bytes(obj.merkleRoot);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "merkleRoot" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch != null) {
|
||||
writer.uint32(26);
|
||||
writer.bytes(obj.epoch);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "epoch" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX != null) {
|
||||
writer.uint32(34);
|
||||
writer.bytes(obj.shareX);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareX" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY != null) {
|
||||
writer.uint32(42);
|
||||
writer.bytes(obj.shareY);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "shareY" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier != null) {
|
||||
writer.uint32(50);
|
||||
writer.bytes(obj.nullifier);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Protocol error: required field "nullifier" was not found in object'
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
},
|
||||
(reader, length) => {
|
||||
const obj: any = {
|
||||
proof: new Uint8Array(0),
|
||||
merkleRoot: new Uint8Array(0),
|
||||
epoch: new Uint8Array(0),
|
||||
shareX: new Uint8Array(0),
|
||||
shareY: new Uint8Array(0),
|
||||
nullifier: new Uint8Array(0),
|
||||
};
|
||||
|
||||
const end = length == null ? reader.len : reader.pos + length;
|
||||
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
obj.proof = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
obj.merkleRoot = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
obj.epoch = reader.bytes();
|
||||
break;
|
||||
case 4:
|
||||
obj.shareX = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
obj.shareY = reader.bytes();
|
||||
break;
|
||||
case 6:
|
||||
obj.nullifier = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.proof == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "proof" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.merkleRoot == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "merkleRoot" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.epoch == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "epoch" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareX == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareX" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.shareY == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "shareY" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.nullifier == null) {
|
||||
throw new Error(
|
||||
'Protocol error: value for required field "nullifier" was not found in protobuf'
|
||||
);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return _codec;
|
||||
};
|
||||
|
||||
export const encode = (obj: RateLimitProof): Uint8Array => {
|
||||
return encodeMessage(obj, RateLimitProof.codec());
|
||||
};
|
||||
|
||||
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
|
||||
return decodeMessage(buf, RateLimitProof.codec());
|
||||
};
|
||||
}
|
||||
|
||||
export interface WakuMessage {
|
||||
payload?: Uint8Array;
|
||||
contentTopic?: string;
|
||||
version?: number;
|
||||
timestampDeprecated?: number;
|
||||
timestamp?: bigint;
|
||||
rateLimitProof?: RateLimitProof;
|
||||
}
|
||||
|
||||
export namespace WakuMessage {
|
||||
|
@ -589,6 +761,11 @@ export namespace WakuMessage {
|
|||
writer.sint64(obj.timestamp);
|
||||
}
|
||||
|
||||
if (obj.rateLimitProof != null) {
|
||||
writer.uint32(170);
|
||||
RateLimitProof.codec().encode(obj.rateLimitProof, writer);
|
||||
}
|
||||
|
||||
if (opts.lengthDelimited !== false) {
|
||||
writer.ldelim();
|
||||
}
|
||||
|
@ -617,6 +794,12 @@ export namespace WakuMessage {
|
|||
case 10:
|
||||
obj.timestamp = reader.sint64();
|
||||
break;
|
||||
case 21:
|
||||
obj.rateLimitProof = RateLimitProof.codec().decode(
|
||||
reader,
|
||||
reader.uint32()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue