From cb696c95b495870cd615173ddd74ea243ce6f5d9 Mon Sep 17 00:00:00 2001 From: Skima Harvey <64636974+skimaharvey@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:22:44 +0000 Subject: [PATCH] fix: add existence check before the _beforeTokenTransfer hook (#844) Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com> --- .../LSP8IdentifiableDigitalAssetCore.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol index 54e1a2350..89f57b15d 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol @@ -507,6 +507,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