Skip to content

Commit

Permalink
fix: rm duplicated code & invalid sig error
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsadface committed Oct 12, 2024
1 parent 7f57a50 commit 9b71ffc
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 82 deletions.
10 changes: 1 addition & 9 deletions script/upgrade/UpdateDefaultStoryNFTTemplate.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ contract UpdateDefaultStoryNFTTemplate is UpgradeHelper {
}

function _updateDefaultStoryNFTTemplate() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("GroupingWorkflows", address(groupingWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_predeploy("DefaultStoryNftTemplate");
StoryBadgeNFT newDefaultStoryNftTemplate = new StoryBadgeNFT(
ipAssetRegistryAddr,
Expand All @@ -48,7 +41,6 @@ contract UpdateDefaultStoryNFTTemplate is UpgradeHelper {
IStoryNFTFactory(storyNftFactoryAddr).setDefaultStoryNftTemplate(address(newDefaultStoryNftTemplate));
console2.log("New DefaultStoryNFTTemplate: ", address(newDefaultStoryNftTemplate));
_postdeploy("DefaultStoryNftTemplate", address(newDefaultStoryNftTemplate));
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("DefaultStoryNftTemplate");
}
}
9 changes: 1 addition & 8 deletions script/upgrade/UpgradeDerivativeWorkflows.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ contract UpgradeDerivativeWorkflows is UpgradeHelper {
);
console2.log("New DerivativeWorkflows Implementation: ", newDerivativeWorkflowsImpl);
_postdeploy("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("DerivativeWorkflows");
}
}
10 changes: 1 addition & 9 deletions script/upgrade/UpgradeGroupingWorkflows.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ contract UpgradeGroupingWorkflows is UpgradeHelper {
}

function _deployGroupingWorkflows() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_predeploy("GroupingWorkflows");
address newGroupingWorkflowsImpl = address(
new GroupingWorkflows(
Expand All @@ -47,13 +46,6 @@ contract UpgradeGroupingWorkflows is UpgradeHelper {
);
console2.log("New GroupingWorkflows Implementation: ", newGroupingWorkflowsImpl);
_postdeploy("GroupingWorkflows", address(groupingWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("GroupingWorkflows");
}
}
10 changes: 1 addition & 9 deletions script/upgrade/UpgradeLicenseAttachmentWorkflows.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ contract UpgradeLicenseAttachmentWorkflows is UpgradeHelper {
}

function _deployLicenseAttachmentWorkflows() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("GroupingWorkflows", address(groupingWorkflows));
_predeploy("LicenseAttachmentWorkflows");
address newLicenseAttachmentWorkflowsImpl = address(
new LicenseAttachmentWorkflows(
Expand All @@ -46,12 +44,6 @@ contract UpgradeLicenseAttachmentWorkflows is UpgradeHelper {
);
console2.log("New LicenseAttachmentWorkflows Implementation: ", newLicenseAttachmentWorkflowsImpl);
_postdeploy("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("LicenseAttachmentWorkflows");
}
}
10 changes: 1 addition & 9 deletions script/upgrade/UpgradeOrgNFT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ contract UpgradeOrgNFT is UpgradeHelper {
}

function _upgradeOrgNFT() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("GroupingWorkflows", address(groupingWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_predeploy("OrgNFT");
OrgNFT newOrgNft = new OrgNFT(
ipAssetRegistryAddr,
Expand All @@ -47,6 +39,6 @@ contract UpgradeOrgNFT is UpgradeHelper {
);
console2.log("New OrgNFT implementation: ", address(newOrgNft));
_postdeploy("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("OrgNFT");
}
}
10 changes: 1 addition & 9 deletions script/upgrade/UpgradeRegistrationWorkflows.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ contract UpgradeRegistrationWorkflows is UpgradeHelper {
}

function _deployRegistrationWorkflows() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("GroupingWorkflows", address(groupingWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_predeploy("RegistrationWorkflows");
address newRegistrationWorkflowsImpl = address(
new RegistrationWorkflows(
Expand All @@ -47,11 +44,6 @@ contract UpgradeRegistrationWorkflows is UpgradeHelper {
);
console2.log("New RegistrationWorkflows Implementation: ", newRegistrationWorkflowsImpl);
_postdeploy("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("RegistrationWorkflows");
}
}
9 changes: 1 addition & 8 deletions script/upgrade/UpgradeRoyaltyWorkflows.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ contract UpgradeRoyaltyWorkflows is UpgradeHelper {
}

function _deployRoyaltyWorkflows() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_predeploy("RoyaltyWorkflows");
address newRoyaltyWorkflowsImpl = address(new RoyaltyWorkflows(royaltyModuleAddr));
console2.log("New RoyaltyWorkflows Implementation: ", newRoyaltyWorkflowsImpl);
_postdeploy("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("RoyaltyWorkflows");
}
}
10 changes: 1 addition & 9 deletions script/upgrade/UpgradeSPGNFT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ contract UpgradeSPGNFT is UpgradeHelper {
}

function _deploySPGNFT() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("GroupingWorkflows", address(groupingWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_predeploy("SPGNFTImpl");
spgNftImpl = new SPGNFT(
address(derivativeWorkflows),
Expand All @@ -46,8 +40,6 @@ contract UpgradeSPGNFT is UpgradeHelper {
);
console2.log("New SPGNFT Implementation: ", address(spgNftImpl));
_postdeploy("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_writeAddress("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("SPGNFTImpl");
}
}
10 changes: 1 addition & 9 deletions script/upgrade/UpgradeStoryNFTFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ contract UpgradeStoryNFTFactory is UpgradeHelper {
}

function _upgradeStoryNFTFactory() private {
_writeAddress("DerivativeWorkflows", address(derivativeWorkflows));
_writeAddress("GroupingWorkflows", address(groupingWorkflows));
_writeAddress("LicenseAttachmentWorkflows", address(licenseAttachmentWorkflows));
_writeAddress("RegistrationWorkflows", address(registrationWorkflows));
_writeAddress("RoyaltyWorkflows", address(royaltyWorkflows));
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));
_writeAddress("SPGNFTImpl", address(spgNftImpl));
_writeAddress("DefaultStoryNftTemplate", defaultStoryNftTemplateAddr);
_writeAddress("OrgNFT", orgNftAddr);
_predeploy("StoryNFTFactory");
StoryNFTFactory newStoryNftFactory = new StoryNFTFactory(
ipAssetRegistryAddr,
Expand All @@ -48,5 +39,6 @@ contract UpgradeStoryNFTFactory is UpgradeHelper {
);
console2.log("New StoryNFTFactory implementation: ", address(newStoryNftFactory));
_postdeploy("StoryNFTFactory", storyNftFactoryAddr);
_writeOtherAddresses("StoryNFTFactory");
}
}
32 changes: 32 additions & 0 deletions script/utils/upgrades/UpgradeHelper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,36 @@ contract UpgradeHelper is
_writeAddress(contractKey, newAddress);
console2.log(string.concat(contractKey, " deployed to:"), newAddress);
}

function _writeOtherAddresses(string memory upgradedContractKey) internal {
string[] memory contractKeys = new string[](10);
contractKeys[0] = "DerivativeWorkflows";
contractKeys[1] = "GroupingWorkflows";
contractKeys[2] = "LicenseAttachmentWorkflows";
contractKeys[3] = "RegistrationWorkflows";
contractKeys[4] = "RoyaltyWorkflows";
contractKeys[5] = "SPGNFTBeacon";
contractKeys[6] = "SPGNFTImpl";
contractKeys[7] = "DefaultStoryNftTemplate";
contractKeys[8] = "OrgNFT";
contractKeys[9] = "StoryNFTFactory";

address[] memory addresses = new address[](10);
addresses[0] = derivativeWorkflowsAddr;
addresses[1] = groupingWorkflowsAddr;
addresses[2] = licenseAttachmentWorkflowsAddr;
addresses[3] = registrationWorkflowsAddr;
addresses[4] = royaltyWorkflowsAddr;
addresses[5] = spgNftBeaconAddr;
addresses[6] = spgNftImplAddr;
addresses[7] = defaultStoryNftTemplateAddr;
addresses[8] = orgNftAddr;
addresses[9] = storyNftFactoryAddr;

for (uint256 i = 0; i < contractKeys.length; i++) {
if (keccak256(abi.encodePacked(contractKeys[i])) == keccak256(abi.encodePacked(upgradedContractKey)))
continue;
_writeAddress(contractKeys[i], addresses[i]);
}
}
}
17 changes: 14 additions & 3 deletions test/integration/workflows/RoyaltyIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ contract RoyaltyIntegration is BaseIntegration {
uint256 deadline = block.timestamp + 1000;

// set permission for licensing module to attach license terms to ancestor IP
(bytes memory signature, , ) = _getSetPermissionSigForPeriphery({
(bytes memory signatureA, , ) = _getSetPermissionSigForPeriphery({
ipId: ancestorIpId,
to: licenseAttachmentWorkflowsAddr,
module: licensingModuleAddr,
Expand All @@ -329,7 +329,18 @@ contract RoyaltyIntegration is BaseIntegration {
royaltyPolicy: royaltyPolicyLRPAddr,
currencyToken: address(StoryUSD)
}),
sigAttach: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, signature: signature })
sigAttach: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, signature: signatureA })
});

// set permission for licensing module to attach license terms to ancestor IP
(bytes memory signatureC, , ) = _getSetPermissionSigForPeriphery({
ipId: ancestorIpId,
to: licenseAttachmentWorkflowsAddr,
module: licensingModuleAddr,
selector: licensingModule.attachLicenseTerms.selector,
deadline: deadline,
state: IIPAccount(payable(ancestorIpId)).state(),
signerSk: testSenderSk
});

commRemixTermsIdC = licenseAttachmentWorkflows.registerPILTermsAndAttach({
Expand All @@ -340,7 +351,7 @@ contract RoyaltyIntegration is BaseIntegration {
royaltyPolicy: royaltyPolicyLAPAddr,
currencyToken: address(StoryUSD)
}),
sigAttach: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, signature: signature })
sigAttach: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, signature: signatureC })
});

// register childIpA as derivative of ancestorIp under Terms A
Expand Down

0 comments on commit 9b71ffc

Please sign in to comment.