Created
April 8, 2019 13:39
-
-
Save daniellehrner/c390df4d985b5ff71ba27a1801aeb103 to your computer and use it in GitHub Desktop.
Iterable Eternal Storage Getter
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
address[] memory addressKeys = getAddressKeys("balanceKeys"); | |
function getAddressKeys(bytes32 _listId) external view returns (address[] memory) { | |
// get the number of keys with _listId "balanceKeys" | |
uint256 size = getUInt256(keccak256(abi.encodePacked(_listId, "KEY_SIZE"))); | |
// create an address array with the size of the list | |
address[] memory keys = new address[](size); | |
// iterate over the list | |
for (uint256 index = 0; index < size; index++) { | |
// get the value at the current index | |
keys[index] = getAddress(keccak256(abi.encodePacked(_listId, "KEY_VALUES", index))); | |
} | |
// return dynamic list of keys | |
return keys; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment