Created
November 1, 2022 15:03
-
-
Save prajwolrg/1490c5e4d91e882f1d21390f37ab644d to your computer and use it in GitHub Desktop.
Accepts the Resource
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
pragma solidity ^0.8.15; | |
function _acceptResource(uint256 tokenId, uint256 index) internal { | |
if (index >= _pendingResources[tokenId].length) | |
revert RMRKIndexOutOfRange(); | |
uint64 resourceId = _pendingResources[tokenId][index]; | |
_pendingResources[tokenId].removeItemByIndex(index); | |
uint64 overwrite = _resourceOverwrites[tokenId][resourceId]; | |
if (overwrite != uint64(0)) { | |
// We could check here that the resource to overwrite actually exists but it is probably harmless. | |
_activeResources[tokenId].removeItemByValue(overwrite); | |
emit ResourceOverwritten(tokenId, overwrite, resourceId); | |
delete (_resourceOverwrites[tokenId][resourceId]); | |
} | |
_activeResources[tokenId].push(resourceId); | |
//Push 0 value of uint16 to array, e.g., uninitialized | |
_activeResourcePriorities[tokenId].push(uint16(0)); | |
emit ResourceAccepted(tokenId, resourceId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment