@waku/rln 0.0.2-09108d9.0 → 0.0.2-3670e82.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.
- package/bundle/_virtual/utils.js +2 -2
- package/bundle/_virtual/utils2.js +2 -2
- package/bundle/index.js +2 -1
- package/bundle/packages/rln/dist/contract/abi.js +648 -0
- package/bundle/packages/rln/dist/contract/constants.js +25 -65
- package/bundle/packages/rln/dist/contract/rln_contract.js +365 -74
- package/bundle/packages/rln/dist/message.js +1 -1
- package/bundle/packages/rln/dist/rln.js +36 -20
- package/bundle/packages/rln/dist/zerokit.js +34 -14
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
- package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/abi.d.ts +46 -0
- package/dist/contract/abi.js +647 -0
- package/dist/contract/abi.js.map +1 -0
- package/dist/contract/constants.d.ts +63 -3
- package/dist/contract/constants.js +23 -64
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_contract.d.ts +100 -17
- package/dist/contract/rln_contract.js +364 -72
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/message.js +1 -1
- package/dist/message.js.map +1 -1
- package/dist/rln.d.ts +5 -1
- package/dist/rln.js +36 -19
- package/dist/rln.js.map +1 -1
- package/dist/zerokit.d.ts +10 -6
- package/dist/zerokit.js +34 -14
- package/dist/zerokit.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/abi.ts +646 -0
- package/src/contract/constants.ts +26 -65
- package/src/contract/rln_contract.ts +578 -108
- package/src/index.ts +4 -9
- package/src/message.ts +1 -1
- package/src/rln.ts +57 -21
- package/src/zerokit.ts +74 -15
@@ -1,68 +1,29 @@
|
|
1
|
-
|
2
|
-
export const RLN_REGISTRY_ABI = [
|
3
|
-
"error IncompatibleStorage()",
|
4
|
-
"error IncompatibleStorageIndex()",
|
5
|
-
"error NoStorageContractAvailable()",
|
6
|
-
"error StorageAlreadyExists(address storageAddress)",
|
7
|
-
"event AdminChanged(address previousAdmin, address newAdmin)",
|
8
|
-
"event BeaconUpgraded(address indexed beacon)",
|
9
|
-
"event Initialized(uint8 version)",
|
10
|
-
"event NewStorageContract(uint16 index, address storageAddress)",
|
11
|
-
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
|
12
|
-
"event Upgraded(address indexed implementation)",
|
13
|
-
"function forceProgress()",
|
14
|
-
"function initialize(address _poseidonHasher)",
|
15
|
-
"function newStorage()",
|
16
|
-
"function nextStorageIndex() view returns (uint16)",
|
17
|
-
"function owner() view returns (address)",
|
18
|
-
"function poseidonHasher() view returns (address)",
|
19
|
-
"function proxiableUUID() view returns (bytes32)",
|
20
|
-
"function register(uint16 storageIndex, uint256 commitment)",
|
21
|
-
"function register(uint256[] commitments)",
|
22
|
-
"function register(uint16 storageIndex, uint256[] commitments)",
|
23
|
-
"function registerStorage(address storageAddress)",
|
24
|
-
"function renounceOwnership()",
|
25
|
-
"function storages(uint16) view returns (address)",
|
26
|
-
"function transferOwnership(address newOwner)",
|
27
|
-
"function upgradeTo(address newImplementation)",
|
28
|
-
"function upgradeToAndCall(address newImplementation, bytes data) payable",
|
29
|
-
"function usingStorageIndex() view returns (uint16)"
|
30
|
-
];
|
31
|
-
|
32
|
-
// ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnStorage_0.json#L3
|
33
|
-
export const RLN_STORAGE_ABI = [
|
34
|
-
"constructor(address _poseidonHasher, uint16 _contractIndex)",
|
35
|
-
"error DuplicateIdCommitment()",
|
36
|
-
"error FullTree()",
|
37
|
-
"error InvalidIdCommitment(uint256 idCommitment)",
|
38
|
-
"error NotImplemented()",
|
39
|
-
"event MemberRegistered(uint256 idCommitment, uint256 index)",
|
40
|
-
"event MemberWithdrawn(uint256 idCommitment, uint256 index)",
|
41
|
-
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
|
42
|
-
"function DEPTH() view returns (uint256)",
|
43
|
-
"function MEMBERSHIP_DEPOSIT() view returns (uint256)",
|
44
|
-
"function SET_SIZE() view returns (uint256)",
|
45
|
-
"function contractIndex() view returns (uint16)",
|
46
|
-
"function deployedBlockNumber() view returns (uint32)",
|
47
|
-
"function idCommitmentIndex() view returns (uint256)",
|
48
|
-
"function isValidCommitment(uint256 idCommitment) view returns (bool)",
|
49
|
-
"function memberExists(uint256) view returns (bool)",
|
50
|
-
"function members(uint256) view returns (uint256)",
|
51
|
-
"function owner() view returns (address)",
|
52
|
-
"function poseidonHasher() view returns (address)",
|
53
|
-
"function register(uint256[] idCommitments)",
|
54
|
-
"function register(uint256 idCommitment) payable",
|
55
|
-
"function renounceOwnership()",
|
56
|
-
"function slash(uint256 idCommitment, address receiver, uint256[8] proof) pure",
|
57
|
-
"function stakedAmounts(uint256) view returns (uint256)",
|
58
|
-
"function transferOwnership(address newOwner)",
|
59
|
-
"function verifier() view returns (address)",
|
60
|
-
"function withdraw() pure",
|
61
|
-
"function withdrawalBalance(address) view returns (uint256)"
|
62
|
-
];
|
1
|
+
import { RLN_ABI } from "./abi.js";
|
63
2
|
|
64
3
|
export const SEPOLIA_CONTRACT = {
|
65
|
-
chainId:
|
66
|
-
|
67
|
-
|
4
|
+
chainId: 59141,
|
5
|
+
// Implementation contract: 0xde2260ca49300357d5af4153cda0d18f7b3ea9b3
|
6
|
+
address: "0xb9cd878c90e49f797b4431fbf4fb333108cb90e6",
|
7
|
+
abi: RLN_ABI
|
68
8
|
};
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Rate limit tiers (messages per epoch)
|
12
|
+
* Each membership can specify a rate limit within these bounds.
|
13
|
+
* @see https://github.com/waku-org/specs/blob/master/standards/core/rln-contract.md#implementation-suggestions
|
14
|
+
*/
|
15
|
+
export const RATE_LIMIT_TIERS = {
|
16
|
+
LOW: 20, // Suggested minimum rate - 20 messages per epoch
|
17
|
+
MEDIUM: 200,
|
18
|
+
HIGH: 600 // Suggested maximum rate - 600 messages per epoch
|
19
|
+
} as const;
|
20
|
+
|
21
|
+
// Global rate limit parameters
|
22
|
+
export const RATE_LIMIT_PARAMS = {
|
23
|
+
MIN_RATE: RATE_LIMIT_TIERS.LOW,
|
24
|
+
MAX_RATE: RATE_LIMIT_TIERS.HIGH,
|
25
|
+
MAX_TOTAL_RATE: 160_000, // Maximum total rate limit across all memberships
|
26
|
+
EPOCH_LENGTH: 600 // Epoch length in seconds (10 minutes)
|
27
|
+
} as const;
|
28
|
+
|
29
|
+
export const DEFAULT_RATE_LIMIT = RATE_LIMIT_PARAMS.MAX_RATE;
|