-
Notifications
You must be signed in to change notification settings - Fork 12k
Add EnumerableMap, refactor ERC721 #2160
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
22 commits
Select commit
Hold shift + click to select a range
a934ca2
Implement AddressSet in terms of a generic Set
nventuro bf2ae57
Add Uint256Set
nventuro bbc2ce6
Add EnumerableMap
nventuro 07fc2d1
Fix wording on EnumerableSet docs and tests
nventuro 56830dc
Refactor ERC721 using EnumerableSet and EnumerableMap
nventuro cfb7d61
Fix tests
nventuro 4288d3f
Fix linter error
nventuro 4ebdf1a
Gas optimization for EnumerableMap
nventuro 09bd74a
Gas optimization for EnumerableSet
nventuro 33c557a
Remove often not-taken if from Enumerable data structures
nventuro e193093
Fix failing test
nventuro 1be5033
Gas optimization for EnumerableMap
nventuro 653041d
Fix linter errors
nventuro 42dd8cd
Add comment for clarification
nventuro c04134b
Improve test naming
nventuro cce8a4d
Rename EnumerableMap.add to set
nventuro 219865a
Add overload for EnumerableMap.get with custom error message
nventuro 69623d3
Merge branch 'master' into erc721-refactor
nventuro a235565
Improve Enumerable docs
nventuro 8083ece
Rename Uint256Set to UintSet
nventuro e87477f
Add changelog entry
nventuro a6249ec
Merge branch 'master' into erc721-refactor
nventuro 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
import "../utils/EnumerableMap.sol"; | ||
|
||
contract EnumerableMapMock { | ||
using EnumerableMap for EnumerableMap.UintToAddressMap; | ||
|
||
event OperationResult(bool result); | ||
|
||
EnumerableMap.UintToAddressMap private _map; | ||
|
||
function contains(uint256 key) public view returns (bool) { | ||
return _map.contains(key); | ||
} | ||
|
||
function set(uint256 key, address value) public { | ||
bool result = _map.set(key, value); | ||
emit OperationResult(result); | ||
} | ||
|
||
function remove(uint256 key) public { | ||
bool result = _map.remove(key); | ||
emit OperationResult(result); | ||
} | ||
|
||
function length() public view returns (uint256) { | ||
return _map.length(); | ||
} | ||
|
||
function at(uint256 index) public view returns (uint256 key, address value) { | ||
return _map.at(index); | ||
} | ||
|
||
|
||
function get(uint256 key) public view returns (address) { | ||
return _map.get(key); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.