generated from vacp2p/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64df459
commit 8be1af6
Showing
9 changed files
with
2,423 additions
and
1,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
WakuRlnV2Test:test__IdCommitmentToMetadata__DoesntExist() (gas: 16726) | ||
WakuRlnV2Test:test__InvalidPaginationQuery__EndIndexGTcommitmentIndex() (gas: 18249) | ||
WakuRlnV2Test:test__InvalidPaginationQuery__StartIndexGTEndIndex() (gas: 16130) | ||
WakuRlnV2Test:test__InvalidRegistration__DuplicateIdCommitment() (gas: 99502) | ||
WakuRlnV2Test:test__InvalidRegistration__FullTree() (gas: 14328) | ||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__LargerThanField() (gas: 15229) | ||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__Zero() (gas: 14004) | ||
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__LargerThanMax() (gas: 17703) | ||
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__Zero() (gas: 14085) | ||
WakuRlnV2Test:test__Upgrade() (gas: 3791109) | ||
WakuRlnV2Test:test__ValidPaginationQuery(uint32) (runs: 1000, μ: 445155, ~: 159972) | ||
WakuRlnV2Test:test__ValidPaginationQuery__OneElement() (gas: 119773) | ||
WakuRlnV2Test:test__ValidRegistration(uint256,uint32) (runs: 1000, μ: 124408, ~: 124408) | ||
WakuRlnV2Test:test__ValidRegistration__kats() (gas: 96616) | ||
WakuRlnV2Test:test__IdCommitmentToMetadata__DoesntExist() (gas: 27478) | ||
WakuRlnV2Test:test__InsertionNormalOrder(uint32) (runs: 1001, μ: 1123469, ~: 494837) | ||
WakuRlnV2Test:test__InvalidPaginationQuery__EndIndexGTcommitmentIndex() (gas: 18261) | ||
WakuRlnV2Test:test__InvalidPaginationQuery__StartIndexGTEndIndex() (gas: 16108) | ||
WakuRlnV2Test:test__InvalidRegistration__DuplicateIdCommitment() (gas: 249370) | ||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__Zero() (gas: 12135) | ||
WakuRlnV2Test:test__Upgrade() (gas: 6728616) | ||
WakuRlnV2Test:test__ValidPaginationQuery(uint32) (runs: 1002, μ: 226428, ~: 52927) | ||
WakuRlnV2Test:test__ValidPaginationQuery__OneElement() (gas: 262351) | ||
WakuRlnV2Test:test__ValidRegistration(uint256,uint32) (runs: 1001, μ: 268741, ~: 268741) | ||
WakuRlnV2Test:test__ValidRegistration__kats() (gas: 238744) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
interface IPriceCalculator { | ||
/// Returns the token and price to pay in `token` for some `_rateLimit` | ||
/// @param _rateLimit the rate limit the user wants to acquire | ||
/// @param _numberOfPeriods the number of periods the user wants to acquire | ||
/// @return address of the erc20 token | ||
/// @return uint price to pay for acquiring the specified `_rateLimit` | ||
function calculate(uint256 _rateLimit, uint32 _numberOfPeriods) external view returns (address, uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; | ||
import { IPriceCalculator } from "./IPriceCalculator.sol"; | ||
|
||
/// @title Linear Price Calculator to determine the price to acquire a membership | ||
contract LinearPriceCalculator is IPriceCalculator, Ownable { | ||
/// @notice Address of the ERC20 token accepted by this contract. Address(0) represents ETH | ||
address public token; | ||
|
||
/// @notice The price per message per epoch per period | ||
uint256 public pricePerMessagePerPeriod; | ||
|
||
constructor(address _token, uint256 _pricePerPeriod) Ownable() { | ||
token = _token; | ||
pricePerMessagePerPeriod = _pricePerPeriod; | ||
} | ||
|
||
/// Set accepted token and price per message per epoch per period | ||
/// @param _token The token accepted by the membership management for RLN | ||
/// @param _pricePerPeriod Price per message per epoch | ||
function setTokenAndPrice(address _token, uint256 _pricePerPeriod) external onlyOwner { | ||
token = _token; | ||
pricePerMessagePerPeriod = _pricePerPeriod; | ||
} | ||
|
||
/// Returns the token and price to pay in `token` for some `_rateLimit` | ||
/// @param _rateLimit the rate limit the user wants to acquire | ||
/// @param _numberOfPeriods the number of periods the user wants to acquire | ||
/// @return address of the erc20 token | ||
/// @return uint price to pay for acquiring the specified `_rateLimit` | ||
function calculate(uint256 _rateLimit, uint32 _numberOfPeriods) external view returns (address, uint256) { | ||
return (token, uint256(_numberOfPeriods) * uint256(_rateLimit) * pricePerMessagePerPeriod); | ||
} | ||
} |
Oops, something went wrong.