From 428f644f99bf33d6c6bb11c588b7debbf402bd89 Mon Sep 17 00:00:00 2001 From: Sebastian Liu Date: Thu, 15 Aug 2024 23:12:58 -0700 Subject: [PATCH] fix(spg): prevent duplicate license terms --- contracts/StoryProtocolGateway.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/StoryProtocolGateway.sol b/contracts/StoryProtocolGateway.sol index c226609..6585a07 100644 --- a/contracts/StoryProtocolGateway.sol +++ b/contracts/StoryProtocolGateway.sol @@ -403,6 +403,11 @@ contract StoryProtocolGateway is IStoryProtocolGateway, AccessManagedUpgradeable PILTerms calldata terms ) internal returns (uint256 licenseTermsId) { licenseTermsId = PIL_TEMPLATE.registerLicenseTerms(terms); + + // Returns the license terms ID if already attached. + if (LICENSE_REGISTRY.hasIpAttachedLicenseTerms(ipId, address(PIL_TEMPLATE), licenseTermsId)) + return licenseTermsId; + LICENSING_MODULE.attachLicenseTerms(ipId, address(PIL_TEMPLATE), licenseTermsId); }