@waku/rln 0.1.5-1d384f2.0 → 0.1.5-1e590d7.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 (133) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +2 -1
  4. package/bundle/packages/rln/dist/contract/constants.js +1 -0
  5. package/bundle/packages/rln/dist/contract/rln_base_contract.js +66 -61
  6. package/bundle/packages/rln/dist/contract/rln_contract.js +1 -1
  7. package/bundle/packages/rln/dist/utils/bytes.js +8 -2
  8. package/bundle/packages/rln/dist/utils/metamask.js +2 -2
  9. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  10. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  11. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +1 -1
  12. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +1 -1
  13. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +1 -1
  14. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +1 -1
  15. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +1 -1
  16. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +1 -1
  17. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +1 -1
  18. package/dist/.tsbuildinfo +1 -1
  19. package/dist/contract/index.d.ts +1 -0
  20. package/dist/contract/index.js +1 -0
  21. package/dist/contract/index.js.map +1 -1
  22. package/dist/contract/rln_base_contract.d.ts +5 -11
  23. package/dist/contract/rln_base_contract.js +64 -59
  24. package/dist/contract/rln_base_contract.js.map +1 -1
  25. package/dist/contract/types.d.ts +5 -0
  26. package/dist/contract/types.js.map +1 -1
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +1 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/keystore/keystore.js.map +1 -1
  31. package/dist/keystore/types.d.ts +2 -2
  32. package/dist/utils/bytes.js +8 -2
  33. package/dist/utils/bytes.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/contract/index.ts +1 -0
  36. package/src/contract/rln_base_contract.ts +96 -89
  37. package/src/contract/types.ts +5 -0
  38. package/src/index.ts +3 -1
  39. package/src/keystore/keystore.ts +4 -2
  40. package/src/keystore/types.ts +2 -2
  41. package/src/utils/bytes.ts +10 -2
  42. package/bundle/_virtual/__node-resolve_empty.js +0 -6
  43. package/bundle/_virtual/_node-resolve_empty.js +0 -3
  44. package/bundle/_virtual/bn.js +0 -3
  45. package/bundle/_virtual/common.js +0 -3
  46. package/bundle/_virtual/common2.js +0 -3
  47. package/bundle/_virtual/hash.js +0 -3
  48. package/bundle/_virtual/inherits_browser.js +0 -3
  49. package/bundle/_virtual/ripemd.js +0 -3
  50. package/bundle/_virtual/sha.js +0 -3
  51. package/bundle/_virtual/sha3.js +0 -3
  52. package/bundle/_virtual/utils3.js +0 -3
  53. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +0 -3
  54. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +0 -96
  55. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +0 -148
  56. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +0 -26
  57. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +0 -20
  58. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +0 -210
  59. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +0 -18
  60. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +0 -30
  61. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +0 -26
  62. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +0 -22
  63. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +0 -43
  64. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +0 -19
  65. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +0 -58
  66. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +0 -854
  67. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +0 -609
  68. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +0 -3
  69. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +0 -66
  70. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +0 -3
  71. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +0 -302
  72. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +0 -3
  73. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +0 -110
  74. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +0 -20
  75. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +0 -120
  76. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +0 -3
  77. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +0 -287
  78. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +0 -3
  79. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +0 -402
  80. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +0 -3
  81. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +0 -8
  82. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +0 -3
  83. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +0 -3
  84. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +0 -893
  85. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +0 -3
  86. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +0 -256
  87. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +0 -36
  88. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +0 -135
  89. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +0 -8
  90. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +0 -64
  91. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +0 -443
  92. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +0 -8
  93. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +0 -660
  94. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +0 -3
  95. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +0 -352
  96. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +0 -3
  97. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +0 -248
  98. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +0 -3
  99. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +0 -127
  100. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +0 -3
  101. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +0 -2007
  102. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +0 -422
  103. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +0 -674
  104. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +0 -132
  105. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +0 -3
  106. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +0 -120
  107. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +0 -8
  108. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +0 -3
  109. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +0 -2430
  110. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +0 -76
  111. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +0 -3
  112. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +0 -219
  113. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +0 -3
  114. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +0 -279
  115. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +0 -3
  116. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +0 -69
  117. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +0 -404
  118. package/bundle/node_modules/bech32/index.js +0 -187
  119. package/bundle/node_modules/bn.js/lib/bn.js +0 -3361
  120. package/bundle/node_modules/hash.js/lib/hash/common.js +0 -97
  121. package/bundle/node_modules/hash.js/lib/hash/hmac.js +0 -51
  122. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +0 -152
  123. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +0 -81
  124. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +0 -33
  125. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +0 -113
  126. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +0 -39
  127. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +0 -336
  128. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +0 -53
  129. package/bundle/node_modules/hash.js/lib/hash/sha.js +0 -14
  130. package/bundle/node_modules/hash.js/lib/hash/utils.js +0 -282
  131. package/bundle/node_modules/hash.js/lib/hash.js +0 -33
  132. package/bundle/node_modules/inherits/inherits_browser.js +0 -33
  133. package/bundle/node_modules/minimalistic-assert/index.js +0 -13
@@ -1,3 +1,3 @@
1
- var utils = {};
1
+ var utils = {exports: {}};
2
2
 
3
- export { utils as __exports };
3
+ export { utils as __module };
@@ -1,3 +1,3 @@
1
- var utils = {exports: {}};
1
+ var utils = {};
2
2
 
3
- export { utils as __module };
3
+ export { utils as __exports };
package/bundle/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export { RLNDecoder, RLNEncoder } from './packages/rln/dist/codec.js';
2
2
  export { RLN_ABI } from './packages/rln/dist/contract/abi.js';
3
3
  export { RLNContract } from './packages/rln/dist/contract/rln_contract.js';
4
- export { LINEA_CONTRACT } from './packages/rln/dist/contract/constants.js';
4
+ export { DEFAULT_RATE_LIMIT, LINEA_CONTRACT, RATE_LIMIT_PARAMS, RATE_LIMIT_TIERS } from './packages/rln/dist/contract/constants.js';
5
+ export { MembershipState } from './packages/rln/dist/contract/types.js';
5
6
  export { RLNBaseContract } from './packages/rln/dist/contract/rln_base_contract.js';
6
7
  export { createRLN } from './packages/rln/dist/create.js';
7
8
  export { RLNCredentialsManager } from './packages/rln/dist/credentials_manager.js';
@@ -12,6 +12,7 @@ const LINEA_CONTRACT = {
12
12
  */
13
13
  const RATE_LIMIT_TIERS = {
14
14
  LOW: 20, // Suggested minimum rate - 20 messages per epoch
15
+ MEDIUM: 200,
15
16
  HIGH: 600 // Suggested maximum rate - 600 messages per epoch
16
17
  };
17
18
  // Global rate limit parameters
@@ -16,8 +16,8 @@ import { Logger } from '../../../utils/dist/logger/index.js';
16
16
  import { RLN_ABI } from './abi.js';
17
17
  import { DEFAULT_RATE_LIMIT, RATE_LIMIT_PARAMS } from './constants.js';
18
18
  import { MembershipState } from './types.js';
19
- import { Contract } from '../../../../node_modules/@ethersproject/contracts/lib.esm/index.js';
20
- import { BigNumber } from '../../../../node_modules/@ethersproject/bignumber/lib.esm/bignumber.js';
19
+ import { Contract } from '@ethersproject/contracts';
20
+ import { BigNumber } from '@ethersproject/bignumber';
21
21
 
22
22
  const log = new Logger("waku:rln:contract:base");
23
23
  class RLNBaseContract {
@@ -33,6 +33,22 @@ class RLNBaseContract {
33
33
  * Allows injecting a mocked contract for testing purposes.
34
34
  */
35
35
  constructor(options) {
36
+ const { address, signer, rateLimit = DEFAULT_RATE_LIMIT, contract } = options;
37
+ log.info("Initializing RLNBaseContract", { address, rateLimit });
38
+ this.contract = contract || new Contract(address, RLN_ABI, signer);
39
+ this.rateLimit = rateLimit;
40
+ try {
41
+ log.info("Setting up event filters");
42
+ // Initialize event filters
43
+ this._membersFilter = this.contract.filters.MembershipRegistered();
44
+ this._membershipErasedFilter = this.contract.filters.MembershipErased();
45
+ this._membersExpiredFilter = this.contract.filters.MembershipExpired();
46
+ log.info("Event filters initialized successfully");
47
+ }
48
+ catch (error) {
49
+ log.error("Failed to initialize event filters", { error });
50
+ throw new Error("Failed to initialize event filters: " + error.message);
51
+ }
36
52
  // Initialize members and subscriptions
37
53
  this.fetchMembers()
38
54
  .then(() => {
@@ -41,14 +57,10 @@ class RLNBaseContract {
41
57
  .catch((error) => {
42
58
  log.error("Failed to initialize members", { error });
43
59
  });
44
- const { address, signer, rateLimit = DEFAULT_RATE_LIMIT, contract } = options;
45
- this.validateRateLimit(rateLimit);
46
- this.contract = contract || new Contract(address, RLN_ABI, signer);
47
- this.rateLimit = rateLimit;
48
- // Initialize event filters
49
- this._membersFilter = this.contract.filters.MembershipRegistered();
50
- this._membershipErasedFilter = this.contract.filters.MembershipErased();
51
- this._membersExpiredFilter = this.contract.filters.MembershipExpired();
60
+ // Validate rate limit asynchronously
61
+ this.validateRateLimit(rateLimit).catch((error) => {
62
+ log.error("Failed to validate initial rate limit", { error });
63
+ });
52
64
  }
53
65
  /**
54
66
  * Gets the current rate limit for this contract instance
@@ -116,7 +128,7 @@ class RLNBaseContract {
116
128
  * @param newRateLimit The new rate limit to use
117
129
  */
118
130
  async setRateLimit(newRateLimit) {
119
- this.validateRateLimit(newRateLimit);
131
+ await this.validateRateLimit(newRateLimit);
120
132
  this.rateLimit = newRateLimit;
121
133
  }
122
134
  get members() {
@@ -247,75 +259,63 @@ class RLNBaseContract {
247
259
  this.processEvents([event]);
248
260
  });
249
261
  }
250
- /**
251
- * Helper method to get remaining messages in current epoch
252
- * @param membershipId The ID of the membership to check
253
- * @returns number of remaining messages allowed in current epoch
254
- */
255
- async getRemainingMessages(membershipId) {
262
+ async getMembershipInfo(idCommitmentBigInt) {
256
263
  try {
257
- const [startTime, , rateLimit] = await this.contract.getMembershipInfo(membershipId);
258
- // Calculate current epoch
259
- const currentTime = Math.floor(Date.now() / 1000);
260
- const epochsPassed = Math.floor((currentTime - startTime) / RATE_LIMIT_PARAMS.EPOCH_LENGTH);
261
- const currentEpochStart = startTime + epochsPassed * RATE_LIMIT_PARAMS.EPOCH_LENGTH;
262
- // Get message count in current epoch using contract's function
263
- const messageCount = await this.contract.getMessageCount(membershipId, currentEpochStart);
264
- return Math.max(0, BigNumber.from(rateLimit)
265
- .sub(BigNumber.from(messageCount))
266
- .toNumber());
267
- }
268
- catch (error) {
269
- log.error(`Error getting remaining messages: ${error.message}`);
270
- return 0; // Fail safe: assume no messages remaining on error
271
- }
272
- }
273
- async getMembershipInfo(idCommitment) {
274
- try {
275
- const [startBlock, endBlock, rateLimit] = await this.contract.getMembershipInfo(idCommitment);
264
+ const membershipData = await this.contract.memberships(idCommitmentBigInt);
276
265
  const currentBlock = await this.contract.provider.getBlockNumber();
266
+ const [depositAmount, activeDuration, gracePeriodStartTimestamp, gracePeriodDuration, rateLimit, index, holder, token] = membershipData;
267
+ const gracePeriodEnd = gracePeriodStartTimestamp.add(gracePeriodDuration);
277
268
  let state;
278
- if (currentBlock < startBlock) {
269
+ if (currentBlock < gracePeriodStartTimestamp.toNumber()) {
279
270
  state = MembershipState.Active;
280
271
  }
281
- else if (currentBlock < endBlock) {
272
+ else if (currentBlock < gracePeriodEnd.toNumber()) {
282
273
  state = MembershipState.GracePeriod;
283
274
  }
284
275
  else {
285
276
  state = MembershipState.Expired;
286
277
  }
287
- const index = await this.getMemberIndex(idCommitment);
288
- if (!index)
289
- return undefined;
290
278
  return {
291
279
  index,
292
- idCommitment,
293
- rateLimit: rateLimit.toNumber(),
294
- startBlock: startBlock.toNumber(),
295
- endBlock: endBlock.toNumber(),
296
- state
280
+ idCommitment: idCommitmentBigInt.toString(),
281
+ rateLimit: Number(rateLimit),
282
+ startBlock: gracePeriodStartTimestamp.toNumber(),
283
+ endBlock: gracePeriodEnd.toNumber(),
284
+ state,
285
+ depositAmount,
286
+ activeDuration,
287
+ gracePeriodDuration,
288
+ holder,
289
+ token
297
290
  };
298
291
  }
299
292
  catch (error) {
293
+ log.error("Error in getMembershipInfo:", error);
300
294
  return undefined;
301
295
  }
302
296
  }
303
- async extendMembership(idCommitment) {
304
- return this.contract.extendMemberships([idCommitment]);
297
+ async extendMembership(idCommitmentBigInt) {
298
+ const tx = await this.contract.extendMemberships([idCommitmentBigInt]);
299
+ await tx.wait();
300
+ return tx;
305
301
  }
306
- async eraseMembership(idCommitment, eraseFromMembershipSet = true) {
307
- return this.contract.eraseMemberships([idCommitment], eraseFromMembershipSet);
302
+ async eraseMembership(idCommitmentBigInt, eraseFromMembershipSet = true) {
303
+ const estimatedGas = await this.contract.estimateGas["eraseMemberships(uint256[],bool)"]([idCommitmentBigInt], eraseFromMembershipSet);
304
+ const gasLimit = estimatedGas.add(10000);
305
+ const tx = await this.contract["eraseMemberships(uint256[],bool)"]([idCommitmentBigInt], eraseFromMembershipSet, { gasLimit });
306
+ await tx.wait();
307
+ return tx;
308
308
  }
309
- async registerMembership(idCommitment, rateLimit = DEFAULT_RATE_LIMIT) {
309
+ async registerMembership(idCommitmentBigInt, rateLimit = DEFAULT_RATE_LIMIT) {
310
310
  if (rateLimit < RATE_LIMIT_PARAMS.MIN_RATE ||
311
311
  rateLimit > RATE_LIMIT_PARAMS.MAX_RATE) {
312
312
  throw new Error(`Rate limit must be between ${RATE_LIMIT_PARAMS.MIN_RATE} and ${RATE_LIMIT_PARAMS.MAX_RATE}`);
313
313
  }
314
- return this.contract.register(idCommitment, rateLimit, []);
314
+ return this.contract.register(idCommitmentBigInt, rateLimit, []);
315
315
  }
316
- async withdraw(token, holder) {
316
+ async withdraw(token, from) {
317
317
  try {
318
- const tx = await this.contract.withdraw(token, { from: holder });
318
+ const tx = await this.contract.withdraw(token, from);
319
319
  await tx.wait();
320
320
  }
321
321
  catch (error) {
@@ -326,7 +326,7 @@ class RLNBaseContract {
326
326
  try {
327
327
  log.info(`Registering identity with rate limit: ${this.rateLimit} messages/epoch`);
328
328
  // Check if the ID commitment is already registered
329
- const existingIndex = await this.getMemberIndex(identity.IDCommitmentBigInt.toString());
329
+ const existingIndex = await this.getMemberIndex(identity.IDCommitmentBigInt);
330
330
  if (existingIndex) {
331
331
  throw new Error(`ID commitment is already registered with index ${existingIndex}`);
332
332
  }
@@ -435,10 +435,15 @@ class RLNBaseContract {
435
435
  * Validates that the rate limit is within the allowed range
436
436
  * @throws Error if the rate limit is outside the allowed range
437
437
  */
438
- validateRateLimit(rateLimit) {
439
- if (rateLimit < RATE_LIMIT_PARAMS.MIN_RATE ||
440
- rateLimit > RATE_LIMIT_PARAMS.MAX_RATE) {
441
- throw new Error(`Rate limit must be between ${RATE_LIMIT_PARAMS.MIN_RATE} and ${RATE_LIMIT_PARAMS.MAX_RATE} messages per epoch`);
438
+ async validateRateLimit(rateLimit) {
439
+ const [minRate, maxRate] = await Promise.all([
440
+ this.contract.minMembershipRateLimit(),
441
+ this.contract.maxMembershipRateLimit()
442
+ ]);
443
+ const minRateNum = BigNumber.from(minRate).toNumber();
444
+ const maxRateNum = BigNumber.from(maxRate).toNumber();
445
+ if (rateLimit < minRateNum || rateLimit > maxRateNum) {
446
+ throw new Error(`Rate limit must be between ${minRateNum} and ${maxRateNum} messages per epoch`);
442
447
  }
443
448
  }
444
449
  get membersFilter() {
@@ -459,9 +464,9 @@ class RLNBaseContract {
459
464
  }
460
465
  return this._membersExpiredFilter;
461
466
  }
462
- async getMemberIndex(idCommitment) {
467
+ async getMemberIndex(idCommitmentBigInt) {
463
468
  try {
464
- const events = await this.contract.queryFilter(this.contract.filters.MembershipRegistered(idCommitment));
469
+ const events = await this.contract.queryFilter(this.contract.filters.MembershipRegistered(idCommitmentBigInt));
465
470
  if (events.length === 0)
466
471
  return undefined;
467
472
  // Get the most recent registration event
@@ -6,7 +6,7 @@ import { Logger } from '../../../utils/dist/logger/index.js';
6
6
  import { MerkleRootTracker } from '../root_tracker.js';
7
7
  import { zeroPadLE } from '../utils/bytes.js';
8
8
  import { RLNBaseContract } from './rln_base_contract.js';
9
- import { BigNumber } from '../../../../node_modules/@ethersproject/bignumber/lib.esm/bignumber.js';
9
+ import { BigNumber } from '@ethersproject/bignumber';
10
10
 
11
11
  const log = new Logger("waku:rln:contract");
12
12
  class RLNContract extends RLNBaseContract {
@@ -45,8 +45,14 @@ function writeUIntLE(buf, value, offset, byteLength, noAssert) {
45
45
  * @returns BigInt
46
46
  */
47
47
  function buildBigIntFromUint8Array(array, byteOffset = 0) {
48
- const dataView = new DataView(array.buffer);
49
- return dataView.getBigUint64(byteOffset, true);
48
+ // Convert byte array to BigInt in big-endian format (to match nwaku)
49
+ let result = 0n;
50
+ // Process all 32 bytes (or the available bytes if less)
51
+ const length = Math.min(array.length - byteOffset, 32);
52
+ for (let i = 0; i < length; i++) {
53
+ result = (result << 8n) | BigInt(array[byteOffset + i]);
54
+ }
55
+ return result;
50
56
  }
51
57
  /**
52
58
  * Fills with zeros to set length
@@ -1,4 +1,4 @@
1
- import { Web3Provider } from '../../../../node_modules/@ethersproject/providers/lib.esm/web3-provider.js';
1
+ import * as providers from '@ethersproject/providers';
2
2
 
3
3
  const extractMetaMaskSigner = async () => {
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -7,7 +7,7 @@ const extractMetaMaskSigner = async () => {
7
7
  throw Error("Missing or invalid Ethereum provider. Please install a Web3 wallet such as MetaMask.");
8
8
  }
9
9
  await ethereum.request({ method: "eth_requestAccounts" });
10
- const provider = new Web3Provider(ethereum, "any");
10
+ const provider = new providers.Web3Provider(ethereum, "any");
11
11
  return provider.getSigner();
12
12
  };
13
13
 
@@ -1,6 +1,6 @@
1
1
  import { __exports as random } from '../../../../../../../_virtual/random.js';
2
2
  import '../../../../@noble/hashes/utils.js';
3
- import { __exports as utils } from '../../../../../../../_virtual/utils.js';
3
+ import { __exports as utils } from '../../../../../../../_virtual/utils2.js';
4
4
 
5
5
  Object.defineProperty(random, "__esModule", { value: true });
6
6
  random.getRandomBytes = random.getRandomBytesSync = void 0;
@@ -1,10 +1,10 @@
1
1
  import { commonjsGlobal } from '../../../../../../../_virtual/_commonjsHelpers.js';
2
2
  import { commonjsRequire } from '../../../../../../../_virtual/_commonjs-dynamic-modules.js';
3
- import { __module as utils } from '../../../../../../../_virtual/utils2.js';
3
+ import { __module as utils } from '../../../../../../../_virtual/utils.js';
4
4
  import '../../../../@noble/hashes/_assert.js';
5
5
  import '../../../../@noble/hashes/utils.js';
6
6
  import { __exports as _assert } from '../../../../../../../_virtual/_assert.js';
7
- import { __exports as utils$1 } from '../../../../../../../_virtual/utils.js';
7
+ import { __exports as utils$1 } from '../../../../../../../_virtual/utils2.js';
8
8
 
9
9
  utils.exports;
10
10
 
@@ -1,7 +1,7 @@
1
1
  import { __exports as _sha2 } from '../../../../../_virtual/_sha2.js';
2
2
  import './_assert.js';
3
3
  import './utils.js';
4
- import { __exports as utils } from '../../../../../_virtual/utils.js';
4
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
5
5
  import { __exports as _assert } from '../../../../../_virtual/_assert.js';
6
6
 
7
7
  Object.defineProperty(_sha2, "__esModule", { value: true });
@@ -1,7 +1,7 @@
1
1
  import { __exports as hmac } from '../../../../../_virtual/hmac.js';
2
2
  import './_assert.js';
3
3
  import './utils.js';
4
- import { __exports as utils } from '../../../../../_virtual/utils.js';
4
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
5
5
  import { __exports as _assert } from '../../../../../_virtual/_assert.js';
6
6
 
7
7
  (function (exports) {
@@ -2,7 +2,7 @@ import { __exports as pbkdf2$1 } from '../../../../../_virtual/pbkdf22.js';
2
2
  import './_assert.js';
3
3
  import './hmac.js';
4
4
  import './utils.js';
5
- import { __exports as utils } from '../../../../../_virtual/utils.js';
5
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
6
6
  import { __exports as _assert } from '../../../../../_virtual/_assert.js';
7
7
  import { __exports as hmac } from '../../../../../_virtual/hmac.js';
8
8
 
@@ -3,7 +3,7 @@ import './_assert.js';
3
3
  import './sha256.js';
4
4
  import './pbkdf2.js';
5
5
  import './utils.js';
6
- import { __exports as utils } from '../../../../../_virtual/utils.js';
6
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
7
7
  import { __exports as _assert } from '../../../../../_virtual/_assert.js';
8
8
  import { __exports as pbkdf2 } from '../../../../../_virtual/pbkdf22.js';
9
9
  import { __exports as sha256 } from '../../../../../_virtual/sha2562.js';
@@ -2,7 +2,7 @@ import { __exports as sha256 } from '../../../../../_virtual/sha2562.js';
2
2
  import './_sha2.js';
3
3
  import './utils.js';
4
4
  import { __exports as _sha2 } from '../../../../../_virtual/_sha2.js';
5
- import { __exports as utils } from '../../../../../_virtual/utils.js';
5
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
6
6
 
7
7
  Object.defineProperty(sha256, "__esModule", { value: true });
8
8
  sha256.sha224 = sha256.sha256 = void 0;
@@ -4,7 +4,7 @@ import './_u64.js';
4
4
  import './utils.js';
5
5
  import { __exports as _u64 } from '../../../../../_virtual/_u64.js';
6
6
  import { __exports as _sha2 } from '../../../../../_virtual/_sha2.js';
7
- import { __exports as utils } from '../../../../../_virtual/utils.js';
7
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
8
8
 
9
9
  Object.defineProperty(sha512, "__esModule", { value: true });
10
10
  sha512.sha384 = sha512.sha512_256 = sha512.sha512_224 = sha512.sha512 = sha512.SHA512 = void 0;
@@ -1,4 +1,4 @@
1
- import { __exports as utils } from '../../../../../_virtual/utils.js';
1
+ import { __exports as utils } from '../../../../../_virtual/utils2.js';
2
2
  import './cryptoBrowser.js';
3
3
  import { __exports as cryptoBrowser } from '../../../../../_virtual/cryptoBrowser.js';
4
4