-
Notifications
You must be signed in to change notification settings - Fork 75
feat(merkle-distributor): Make claim only callable by recipient or whitelisted claimer #195
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
df0e275
feat(merkle-distributor): Make claim only callable by recipient
nicholaspai 412ae9a
Add claimFor
nicholaspai 996715e
Reset
nicholaspai be6898c
Update MerkleDistributor.sol
nicholaspai a309706
Update MerkleDistributor.ts
nicholaspai fa25ab6
Update MerkleDistributor.ts
nicholaspai 88601de
Update MerkleDistributor.ts
nicholaspai 544e96f
Update MerkleDistributor.sol
nicholaspai ee114be
Use interface
nicholaspai 08f343c
WIP
nicholaspai c3c7ab0
Bump contracts to 0.40
nicholaspai 15ba83b
Update contracts/merkle-distributor/AcrossMerkleDistributor.sol
nicholaspai 819a95c
Update package.json
nicholaspai df841dc
Update AcrossMerkleDistributor.sol
nicholaspai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,64 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-only | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "@uma/core/contracts/merkle-distributor/implementation/MerkleDistributor.sol"; | ||
|
|
||
| /** | ||
| * @title Extended MerkleDistributor contract. | ||
| * @notice Adds additional constraints governing who can claim leaves from merkle windows. | ||
| */ | ||
| contract AcrossMerkleDistributor is MerkleDistributor { | ||
| // Addresses that can claim on user's behalf. Useful to get around the requirement that claim recipient | ||
| // must also be claimer. | ||
| mapping(address => bool) public whitelistedClaimers; | ||
|
|
||
| /**************************************** | ||
| * EVENTS | ||
| ****************************************/ | ||
| event WhitelistedClaimer(address indexed claimer, bool indexed whitelist); | ||
|
|
||
| /**************************** | ||
| * ADMIN FUNCTIONS | ||
| ****************************/ | ||
|
|
||
| /** | ||
| * @notice Updates whitelisted claimer status. | ||
| * @dev Callable only by owner. | ||
| * @param newContract Reset claimer contract to this address. | ||
| * @param whitelist True to whitelist claimer, False otherwise. | ||
| */ | ||
| function whitelistClaimer(address newContract, bool whitelist) external onlyOwner { | ||
| whitelistedClaimers[newContract] = whitelist; | ||
| emit WhitelistedClaimer(newContract, whitelist); | ||
| } | ||
|
|
||
| /**************************** | ||
| * NON-ADMIN FUNCTIONS | ||
| ****************************/ | ||
|
|
||
| /** | ||
| * @notice Batch claims to reduce gas versus individual submitting all claims. Method will fail | ||
| * if any individual claims within the batch would fail. | ||
| * @dev All claim recipients must be equal to msg.sender or claimer must be whitelisted. | ||
| * @param claims array of claims to claim. | ||
| */ | ||
| function claimMulti(Claim[] memory claims) public override { | ||
| if (!whitelistedClaimers[msg.sender]) { | ||
| uint256 claimCount = claims.length; | ||
| for (uint256 i = 0; i < claimCount; i++) { | ||
| require(claims[i].account == msg.sender, "invalid claimer"); | ||
| } | ||
| } | ||
| super.claimMulti(claims); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Claim amount of reward tokens for account, as described by Claim input object. | ||
| * @dev Claim recipient must be equal to msg.sender or caller must be whitelisted. | ||
| * @param _claim claim object describing amount, accountIndex, account, window index, and merkle proof. | ||
| */ | ||
| function claim(Claim memory _claim) public override { | ||
| require(whitelistedClaimers[msg.sender] || _claim.account == msg.sender, "invalid claimer"); | ||
| super.claim(_claim); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming
claimMultiandclaimfrom within the MerkleDistributor works correctly, this wrapper contract looks perfect to me!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup and the tests give me confidence, which i didn't modify and should work against the parent's behavior