Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Ownable2StepUpgradeable to OwnableUpgradeable #21

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/LinearPriceCalculator.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { Ownable2Step } from "openzeppelin-contracts/contracts/access/Ownable2Step.sol";
import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol";
import { IPriceCalculator } from "./IPriceCalculator.sol";

/// Address 0x0000...0000 was used instead of an ERC20 token address
error OnlyTokensAllowed();

/// @title Linear Price Calculator to determine the price to acquire a membership
contract LinearPriceCalculator is IPriceCalculator, Ownable2Step {
contract LinearPriceCalculator is IPriceCalculator, Ownable {
/// @notice Address of the ERC20 token accepted by this contract.
address public token;

/// @notice The price per message per epoch
uint256 public pricePerMessagePerEpoch;

constructor(address _token, uint256 _pricePerMessagePerEpoch) Ownable2Step() {
constructor(address _token, uint256 _pricePerMessagePerEpoch) Ownable() {
_setTokenAndPrice(_token, _pricePerMessagePerEpoch);
}

Expand Down
4 changes: 2 additions & 2 deletions src/WakuRlnV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { LazyIMT, LazyIMTData } from "@zk-kit/imt.sol/LazyIMT.sol";
import { PoseidonT3 } from "poseidon-solidity/PoseidonT3.sol";

import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

Expand All @@ -20,7 +20,7 @@
/// Invalid pagination query
error InvalidPaginationQuery(uint256 startIndex, uint256 endIndex);

contract WakuRlnV2 is Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, MembershipUpgradeable {
contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable, MembershipUpgradeable {
/// @notice The Field
uint256 public constant Q =
21_888_242_871_839_275_222_246_405_745_257_275_088_548_364_400_416_034_343_698_204_186_575_808_495_617;
Expand All @@ -29,7 +29,7 @@
uint8 public constant MERKLE_TREE_DEPTH = 20;

/// @notice The maximum membership set size is the size of the Merkle tree (2 ^ depth)
uint32 public MAX_MEMBERSHIP_SET_SIZE;

Check warning on line 32 in src/WakuRlnV2.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

/// @notice The block number at which this contract was deployed
uint32 public deployedBlockNumber;
Expand All @@ -47,7 +47,7 @@
/// @notice Сheck that the membership with this idCommitment is not already in the membership set
/// @param idCommitment The idCommitment of the membership
modifier noDuplicateMembership(uint256 idCommitment) {
require(!isInMembershipSet(idCommitment), "Duplicate idCommitment: membership already exists");

Check warning on line 50 in src/WakuRlnV2.sol

View workflow job for this annotation

GitHub Actions / lint

Error message for require is too long
_;
}

Expand Down Expand Up @@ -271,14 +271,14 @@
/// @notice Set the maximum total rate limit of all memberships in the membership set
/// @param _maxTotalRateLimit new maximum total rate limit (messages per epoch)
function setMaxTotalRateLimit(uint32 _maxTotalRateLimit) external onlyOwner {
require(maxMembershipRateLimit <= _maxTotalRateLimit);

Check warning on line 274 in src/WakuRlnV2.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for require
maxTotalRateLimit = _maxTotalRateLimit;
}

/// @notice Set the maximum rate limit of one membership
/// @param _maxMembershipRateLimit new maximum rate limit per membership (messages per epoch)
function setMaxMembershipRateLimit(uint32 _maxMembershipRateLimit) external onlyOwner {
require(minMembershipRateLimit <= _maxMembershipRateLimit);

Check warning on line 281 in src/WakuRlnV2.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for require
maxMembershipRateLimit = _maxMembershipRateLimit;
}

Expand Down
5 changes: 2 additions & 3 deletions test/WakuRlnV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,7 @@ contract WakuRlnV2Test is Test {

/*| Name | Type | Slot | Offset | Bytes |
|---------------------|-----------------------------------------------------|------|--------|-------|
| nextFreeIndex | uint32 | 256 | 0 | 4 | */

| nextFreeIndex | uint32 | 206 | 0 | 4 | */
/*
Pro tip: to easily find the storage slot of a variable, without having to calculate the storage layout
based on the variable declaration, set the variable to an easily grepable value like 0xDEADBEEF, and then
Expand All @@ -710,7 +709,7 @@ contract WakuRlnV2Test is Test {
*/

// we set nextFreeIndex to 4294967295 (1 << 20) = 0x00100000
vm.store(address(w), bytes32(uint256(256)), 0x0000000000000000000000000000000000000000000000000000000000100000);
vm.store(address(w), bytes32(uint256(206)), 0x0000000000000000000000000000000000000000000000000000000000100000);
token.approve(address(w), price);
vm.expectRevert(bytes("Membership set is full"));
w.register(1, membershipRateLimit, noIdCommitmentsToErase);
Expand Down
Loading