@waku/rln 0.1.7-987c6cd.0 → 0.1.7-c24842a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/bundle/packages/core/dist/lib/connection_manager/connection_limiter.js +1 -1
  2. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +1 -1
  3. package/bundle/packages/core/dist/lib/connection_manager/dialer.js +1 -1
  4. package/bundle/packages/core/dist/lib/connection_manager/discovery_dialer.js +1 -1
  5. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +1 -1
  6. package/bundle/packages/core/dist/lib/connection_manager/shard_reader.js +1 -1
  7. package/bundle/packages/core/dist/lib/filter/filter.js +1 -1
  8. package/bundle/packages/core/dist/lib/light_push/light_push.js +1 -1
  9. package/bundle/packages/core/dist/lib/metadata/metadata.js +1 -1
  10. package/bundle/packages/core/dist/lib/store/store.js +1 -1
  11. package/bundle/packages/interfaces/dist/connection_manager.js +1 -0
  12. package/bundle/packages/interfaces/dist/{health_indicator.js → health_status.js} +10 -5
  13. package/bundle/packages/proto/dist/generated/light_push.js +160 -1
  14. package/bundle/packages/rln/dist/codec.js +1 -1
  15. package/bundle/packages/rln/dist/contract/rln_base_contract.js +10 -3
  16. package/bundle/packages/rln/dist/contract/rln_contract.js +1 -1
  17. package/bundle/packages/rln/dist/credentials_manager.js +1 -1
  18. package/bundle/packages/rln/dist/keystore/keystore.js +1 -1
  19. package/bundle/packages/rln/dist/message.js +1 -1
  20. package/bundle/packages/rln/dist/rln.js +1 -1
  21. package/bundle/packages/rln/dist/utils/epoch.js +1 -1
  22. package/bundle/packages/utils/dist/common/sharding/index.js +1 -1
  23. package/dist/.tsbuildinfo +1 -1
  24. package/dist/contract/rln_base_contract.d.ts +5 -3
  25. package/dist/contract/rln_base_contract.js +9 -2
  26. package/dist/contract/rln_base_contract.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/contract/rln_base_contract.ts +14 -3
  29. package/dist/contract/price_calculator.test.d.ts +0 -1
  30. package/dist/contract/price_calculator.test.js +0 -28
  31. package/dist/contract/price_calculator.test.js.map +0 -1
  32. package/src/contract/price_calculator.test.ts +0 -36
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../proto/dist/generated/message.js';
5
5
  import '../../../../proto/dist/generated/filter.js';
6
6
  import '../../../../proto/dist/generated/topic_only_message.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../proto/dist/generated/message.js';
5
5
  import '../../../../proto/dist/generated/filter.js';
6
6
  import '../../../../proto/dist/generated/topic_only_message.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../../interfaces/dist/protocols.js';
2
2
  import '../../../../interfaces/dist/connection_manager.js';
3
- import '../../../../interfaces/dist/health_indicator.js';
3
+ import '../../../../interfaces/dist/health_status.js';
4
4
  import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,3 +1,4 @@
1
+ // Peer tags
1
2
  var Tags;
2
3
  (function (Tags) {
3
4
  Tags["BOOTSTRAP"] = "bootstrap";
@@ -1,12 +1,17 @@
1
- var HealthStatusChangeEvents;
2
- (function (HealthStatusChangeEvents) {
3
- HealthStatusChangeEvents["StatusChange"] = "health:change";
4
- })(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
5
1
  var HealthStatus;
6
2
  (function (HealthStatus) {
3
+ /**
4
+ * No peer connections
5
+ */
7
6
  HealthStatus["Unhealthy"] = "Unhealthy";
7
+ /**
8
+ * At least 1 peer supporting both Filter and LightPush protocols
9
+ */
8
10
  HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
11
+ /**
12
+ * At least 2 peers supporting both Filter and LightPush protocols
13
+ */
9
14
  HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
10
15
  })(HealthStatus || (HealthStatus = {}));
11
16
 
12
- export { HealthStatus, HealthStatusChangeEvents };
17
+ export { HealthStatus };
@@ -87,6 +87,18 @@ var PushResponse;
87
87
  w.uint32(18);
88
88
  w.string(obj.info);
89
89
  }
90
+ if (obj.statusCode != null) {
91
+ w.uint32(80);
92
+ w.uint32(obj.statusCode);
93
+ }
94
+ if (obj.statusDesc != null) {
95
+ w.uint32(90);
96
+ w.string(obj.statusDesc);
97
+ }
98
+ if (obj.relayPeerCount != null) {
99
+ w.uint32(96);
100
+ w.uint32(obj.relayPeerCount);
101
+ }
90
102
  if (opts.lengthDelimited !== false) {
91
103
  w.ldelim();
92
104
  }
@@ -106,6 +118,18 @@ var PushResponse;
106
118
  obj.info = reader.string();
107
119
  break;
108
120
  }
121
+ case 10: {
122
+ obj.statusCode = reader.uint32();
123
+ break;
124
+ }
125
+ case 11: {
126
+ obj.statusDesc = reader.string();
127
+ break;
128
+ }
129
+ case 12: {
130
+ obj.relayPeerCount = reader.uint32();
131
+ break;
132
+ }
109
133
  default: {
110
134
  reader.skipType(tag & 7);
111
135
  break;
@@ -190,6 +214,141 @@ var PushRpc$1;
190
214
  return decodeMessage(buf, PushRpc.codec(), opts);
191
215
  };
192
216
  })(PushRpc$1 || (PushRpc$1 = {}));
217
+ var LightPushRequestV3;
218
+ (function (LightPushRequestV3) {
219
+ let _codec;
220
+ LightPushRequestV3.codec = () => {
221
+ if (_codec == null) {
222
+ _codec = message((obj, w, opts = {}) => {
223
+ if (opts.lengthDelimited !== false) {
224
+ w.fork();
225
+ }
226
+ if ((obj.requestId != null && obj.requestId !== '')) {
227
+ w.uint32(10);
228
+ w.string(obj.requestId);
229
+ }
230
+ if (obj.pubsubTopic != null) {
231
+ w.uint32(162);
232
+ w.string(obj.pubsubTopic);
233
+ }
234
+ if (obj.message != null) {
235
+ w.uint32(170);
236
+ WakuMessage.codec().encode(obj.message, w);
237
+ }
238
+ if (opts.lengthDelimited !== false) {
239
+ w.ldelim();
240
+ }
241
+ }, (reader, length, opts = {}) => {
242
+ const obj = {
243
+ requestId: ''
244
+ };
245
+ const end = length == null ? reader.len : reader.pos + length;
246
+ while (reader.pos < end) {
247
+ const tag = reader.uint32();
248
+ switch (tag >>> 3) {
249
+ case 1: {
250
+ obj.requestId = reader.string();
251
+ break;
252
+ }
253
+ case 20: {
254
+ obj.pubsubTopic = reader.string();
255
+ break;
256
+ }
257
+ case 21: {
258
+ obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {
259
+ limits: opts.limits?.message
260
+ });
261
+ break;
262
+ }
263
+ default: {
264
+ reader.skipType(tag & 7);
265
+ break;
266
+ }
267
+ }
268
+ }
269
+ return obj;
270
+ });
271
+ }
272
+ return _codec;
273
+ };
274
+ LightPushRequestV3.encode = (obj) => {
275
+ return encodeMessage(obj, LightPushRequestV3.codec());
276
+ };
277
+ LightPushRequestV3.decode = (buf, opts) => {
278
+ return decodeMessage(buf, LightPushRequestV3.codec(), opts);
279
+ };
280
+ })(LightPushRequestV3 || (LightPushRequestV3 = {}));
281
+ var LightPushResponseV3;
282
+ (function (LightPushResponseV3) {
283
+ let _codec;
284
+ LightPushResponseV3.codec = () => {
285
+ if (_codec == null) {
286
+ _codec = message((obj, w, opts = {}) => {
287
+ if (opts.lengthDelimited !== false) {
288
+ w.fork();
289
+ }
290
+ if ((obj.requestId != null && obj.requestId !== '')) {
291
+ w.uint32(10);
292
+ w.string(obj.requestId);
293
+ }
294
+ if ((obj.statusCode != null && obj.statusCode !== 0)) {
295
+ w.uint32(80);
296
+ w.uint32(obj.statusCode);
297
+ }
298
+ if (obj.statusDesc != null) {
299
+ w.uint32(90);
300
+ w.string(obj.statusDesc);
301
+ }
302
+ if (obj.relayPeerCount != null) {
303
+ w.uint32(96);
304
+ w.uint32(obj.relayPeerCount);
305
+ }
306
+ if (opts.lengthDelimited !== false) {
307
+ w.ldelim();
308
+ }
309
+ }, (reader, length, opts = {}) => {
310
+ const obj = {
311
+ requestId: '',
312
+ statusCode: 0
313
+ };
314
+ const end = length == null ? reader.len : reader.pos + length;
315
+ while (reader.pos < end) {
316
+ const tag = reader.uint32();
317
+ switch (tag >>> 3) {
318
+ case 1: {
319
+ obj.requestId = reader.string();
320
+ break;
321
+ }
322
+ case 10: {
323
+ obj.statusCode = reader.uint32();
324
+ break;
325
+ }
326
+ case 11: {
327
+ obj.statusDesc = reader.string();
328
+ break;
329
+ }
330
+ case 12: {
331
+ obj.relayPeerCount = reader.uint32();
332
+ break;
333
+ }
334
+ default: {
335
+ reader.skipType(tag & 7);
336
+ break;
337
+ }
338
+ }
339
+ }
340
+ return obj;
341
+ });
342
+ }
343
+ return _codec;
344
+ };
345
+ LightPushResponseV3.encode = (obj) => {
346
+ return encodeMessage(obj, LightPushResponseV3.codec());
347
+ };
348
+ LightPushResponseV3.decode = (buf, opts) => {
349
+ return decodeMessage(buf, LightPushResponseV3.codec(), opts);
350
+ };
351
+ })(LightPushResponseV3 || (LightPushResponseV3 = {}));
193
352
  var RateLimitProof;
194
353
  (function (RateLimitProof) {
195
354
  let _codec;
@@ -388,4 +547,4 @@ var WakuMessage;
388
547
  };
389
548
  })(WakuMessage || (WakuMessage = {}));
390
549
 
391
- export { PushRequest, PushResponse, PushRpc$1 as PushRpc, RateLimitProof, WakuMessage };
550
+ export { LightPushRequestV3, LightPushResponseV3, PushRequest, PushResponse, PushRpc$1 as PushRpc, RateLimitProof, WakuMessage };
@@ -1,6 +1,6 @@
1
1
  import '../../interfaces/dist/protocols.js';
2
2
  import '../../interfaces/dist/connection_manager.js';
3
- import '../../interfaces/dist/health_indicator.js';
3
+ import '../../interfaces/dist/health_status.js';
4
4
  import '../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../interfaces/dist/protocols.js';
2
2
  import '../../../interfaces/dist/connection_manager.js';
3
- import '../../../interfaces/dist/health_indicator.js';
3
+ import '../../../interfaces/dist/health_status.js';
4
4
  import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -533,11 +533,18 @@ class RLNBaseContract {
533
533
  }
534
534
  /**
535
535
  * Calculates the price for a given rate limit using the PriceCalculator contract
536
+ * @param rateLimit The rate limit to calculate the price for
537
+ * @param contractFactory Optional factory for creating the contract (for testing)
536
538
  */
537
- async getPriceForRateLimit(rateLimit) {
539
+ async getPriceForRateLimit(rateLimit, contractFactory) {
538
540
  const provider = this.contract.provider;
539
- const priceCalculator = new Contract(PRICE_CALCULATOR_CONTRACT.address, PRICE_CALCULATOR_CONTRACT.abi, provider);
541
+ const ContractCtor = contractFactory || Contract;
542
+ const priceCalculator = new ContractCtor(PRICE_CALCULATOR_CONTRACT.address, PRICE_CALCULATOR_CONTRACT.abi, provider);
540
543
  const [token, price] = await priceCalculator.calculate(rateLimit);
544
+ // Defensive: if token or price is null/undefined, return nulls
545
+ if (!token || !price) {
546
+ return { token: null, price: null };
547
+ }
541
548
  return { token, price };
542
549
  }
543
550
  }
@@ -1,6 +1,6 @@
1
1
  import '../../../interfaces/dist/protocols.js';
2
2
  import '../../../interfaces/dist/connection_manager.js';
3
- import '../../../interfaces/dist/health_indicator.js';
3
+ import '../../../interfaces/dist/health_status.js';
4
4
  import { hexToBytes } from '../../../utils/dist/bytes/index.js';
5
5
  import { Logger } from '../../../utils/dist/logger.js';
6
6
  import { MerkleRootTracker } from '../root_tracker.js';
@@ -2,7 +2,7 @@ import { hmac } from '../../../node_modules/@noble/hashes/esm/hmac.js';
2
2
  import { sha256 } from '../../../node_modules/@noble/hashes/esm/sha2.js';
3
3
  import '../../interfaces/dist/protocols.js';
4
4
  import '../../interfaces/dist/connection_manager.js';
5
- import '../../interfaces/dist/health_indicator.js';
5
+ import '../../interfaces/dist/health_status.js';
6
6
  import '../../../node_modules/multiformats/dist/src/bases/base10.js';
7
7
  import '../../../node_modules/multiformats/dist/src/bases/base16.js';
8
8
  import '../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,7 +1,7 @@
1
1
  import '../../../../node_modules/@chainsafe/bls-keystore/lib/index.js';
2
2
  import '../../../interfaces/dist/protocols.js';
3
3
  import '../../../interfaces/dist/connection_manager.js';
4
- import '../../../interfaces/dist/health_indicator.js';
4
+ import '../../../interfaces/dist/health_status.js';
5
5
  import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
6
6
  import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
7
7
  import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -5,7 +5,7 @@ import '../../core/dist/lib/store/store.js';
5
5
  import '../../core/dist/lib/connection_manager/connection_manager.js';
6
6
  import '../../interfaces/dist/protocols.js';
7
7
  import '../../interfaces/dist/connection_manager.js';
8
- import '../../interfaces/dist/health_indicator.js';
8
+ import '../../interfaces/dist/health_status.js';
9
9
  import { utf8ToBytes } from '../../utils/dist/bytes/index.js';
10
10
  import '../../../node_modules/debug/src/browser.js';
11
11
  import '../../core/dist/lib/metadata/metadata.js';
@@ -5,7 +5,7 @@ import '../../core/dist/lib/store/store.js';
5
5
  import '../../core/dist/lib/connection_manager/connection_manager.js';
6
6
  import '../../interfaces/dist/protocols.js';
7
7
  import '../../interfaces/dist/connection_manager.js';
8
- import '../../interfaces/dist/health_indicator.js';
8
+ import '../../interfaces/dist/health_status.js';
9
9
  import '../../../node_modules/multiformats/dist/src/bases/base10.js';
10
10
  import '../../../node_modules/multiformats/dist/src/bases/base16.js';
11
11
  import '../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -1,6 +1,6 @@
1
1
  import '../../../interfaces/dist/protocols.js';
2
2
  import '../../../interfaces/dist/connection_manager.js';
3
- import '../../../interfaces/dist/health_indicator.js';
3
+ import '../../../interfaces/dist/health_status.js';
4
4
  import '../../../../node_modules/multiformats/dist/src/bases/base10.js';
5
5
  import '../../../../node_modules/multiformats/dist/src/bases/base16.js';
6
6
  import '../../../../node_modules/multiformats/dist/src/bases/base2.js';
@@ -2,7 +2,7 @@ import { sha256 } from '../../../../../node_modules/@noble/hashes/esm/sha256.js'
2
2
  import '../../../../interfaces/dist/protocols.js';
3
3
  import '../../../../interfaces/dist/connection_manager.js';
4
4
  import { DEFAULT_CLUSTER_ID } from '../../../../interfaces/dist/constants.js';
5
- import '../../../../interfaces/dist/health_indicator.js';
5
+ import '../../../../interfaces/dist/health_status.js';
6
6
  import { concat, utf8ToBytes } from '../../bytes/index.js';
7
7
 
8
8
  const singleShardInfoToPubsubTopic = (shardInfo) => {