-
Notifications
You must be signed in to change notification settings - Fork 563
Cleanup claim condition extension classes #171
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
6 commits
Select commit
Hold shift + click to select a range
1d52bb6
cleanup claim condition extension classes
joaquim-verges 0146f38
fix import casing
joaquim-verges 4052377
more cleanup, fix foundry config
joaquim-verges d1a4044
Merge branch 'main' into joaquim/cleanup_extensions
joaquim-verges e58699e
rename Bitmaps to TWBitMaps
joaquim-verges d783f63
fix imports
joaquim-verges 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts v4.4.1 (utils/structs/BitMaps.sol) | ||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. | ||
* Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. | ||
*/ | ||
library TWBitMaps { | ||
struct BitMap { | ||
mapping(uint256 => uint256) _data; | ||
} | ||
|
||
/** | ||
* @dev Returns whether the bit at `index` is set. | ||
*/ | ||
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { | ||
uint256 bucket = index >> 8; | ||
uint256 mask = 1 << (index & 0xff); | ||
return bitmap._data[bucket] & mask != 0; | ||
} | ||
|
||
/** | ||
* @dev Sets the bit at `index` to the boolean `value`. | ||
*/ | ||
function setTo( | ||
BitMap storage bitmap, | ||
uint256 index, | ||
bool value | ||
) internal { | ||
if (value) { | ||
set(bitmap, index); | ||
} else { | ||
unset(bitmap, index); | ||
} | ||
} | ||
|
||
/** | ||
* @dev Sets the bit at `index`. | ||
*/ | ||
function set(BitMap storage bitmap, uint256 index) internal { | ||
uint256 bucket = index >> 8; | ||
uint256 mask = 1 << (index & 0xff); | ||
bitmap._data[bucket] |= mask; | ||
} | ||
|
||
/** | ||
* @dev Unsets the bit at `index`. | ||
*/ | ||
function unset(BitMap storage bitmap, uint256 index) internal { | ||
uint256 bucket = index >> 8; | ||
uint256 mask = 1 << (index & 0xff); | ||
bitmap._data[bucket] &= ~mask; | ||
} | ||
} |
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.
only thing that's maybe a weird pattern is this. But saves us from inheriting ContextExecutable which adds burden for most ppl who don't use meta-tx.
let me know what you think @nkrishang @jakeloo
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 this is similar to ERC721A pattern, maybe we can turn this into
_thirdwebMsgSender()
and we use it across the board or do you think this has to be isolated to each feature offeringThere 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.
Pb is that it will clash if we declare it multiple times... So annoying. Hope solidity gets better overtime with this