Skip to content

Commit

Permalink
fix: add existence check before the _beforeTokenTransfer hook (#844)
Browse files Browse the repository at this point in the history
Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>
  • Loading branch information
skimaharvey and CJ42 committed Jan 11, 2024
1 parent 7538b89 commit e29f8c9
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
revert LSP8CannotSendToAddressZero();
}

// Check that `tokenId` is not already minted
if (_exists(tokenId)) {
revert LSP8TokenIdAlreadyMinted(tokenId);
}

_beforeTokenTransfer(address(0), to, tokenId, data);

// Check that `tokenId` was not minted inside the `_beforeTokenTransfer` hook
Expand Down Expand Up @@ -721,8 +726,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
* @dev Attempt to notify the operator `operator` about the `tokenId` being authorized.
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
* If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
* @param operator The address to call the {universalReceiver} function on.
* @param operator The address to call the {universalReceiver} function on.
* @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
*/
function _notifyTokenOperator(
Expand All @@ -740,8 +745,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
* @dev Attempt to notify the token sender `from` about the `tokenId` being transferred.
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
* If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
* @param from The address to call the {universalReceiver} function on.
* @param from The address to call the {universalReceiver} function on.
* @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
*/
function _notifyTokenSender(
Expand Down

0 comments on commit e29f8c9

Please sign in to comment.