Skip to content

Commit

Permalink
chore: lint, naming, comments & update package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsadface committed Aug 31, 2024
1 parent d173ea6 commit 341eb2d
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 63 deletions.
37 changes: 18 additions & 19 deletions contracts/GroupingWorkflow.sol → contracts/GroupingWorkflows.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import { ISPGNFT } from "./interfaces/ISPGNFT.sol";
import { MetadataHelper } from "./lib/MetadataHelper.sol";
import { LicensingHelper } from "./lib/LicensingHelper.sol";
import { PermissionHelper } from "./lib/PermissionHelper.sol";
import { IGroupingWorkflow } from "./interfaces/IGroupingWorkflow.sol";
import { IGroupingWorkflows } from "./interfaces/IGroupingWorkflows.sol";
import { IStoryProtocolGateway as ISPG } from "./interfaces/IStoryProtocolGateway.sol";

/// @title Grouping Workflow
/// @title Grouping Workflows
/// @notice This contract provides key workflows for engaging with Group IPA features in
/// Story’s Proof of Creativity protocol.
contract GroupingWorkflow is
IGroupingWorkflow,
contract GroupingWorkflows is
IGroupingWorkflows,
BaseWorkflow,
MulticallUpgradeable,
AccessManagedUpgradeable,
Expand All @@ -37,16 +37,15 @@ contract GroupingWorkflow is

/// @dev Storage structure for the Grouping Workflow.
/// @param nftContractBeacon The address of the NFT contract beacon.
/// @custom:storage-location erc7201:story-protocol-periphery.GroupingWorkflow
struct GroupingWorkflowStorage {
/// @custom:storage-location erc7201:story-protocol-periphery.GroupingWorkflows
struct GroupingWorkflowsStorage {
address nftContractBeacon;
}

/* solhint-disable */
// keccak256(abi.encode(uint256(keccak256("story-protocol-periphery.GroupingWorkflow")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant GroupingWorkflowStorageLocation =
0x4857a9bcc504d5c12cd2c114418794d56adfd4110e9bf90f57ba93c59e7f6200;
/* solhint-enable */
// solhint-disable-next-line max-line-length
// keccak256(abi.encode(uint256(keccak256("story-protocol-periphery.GroupingWorkflows")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant GroupingWorkflowsStorageLocation =
0xa8ddbb5f662015e2b3d6b4c61921979ad3d3d1d19e338b1c4ba6a196b10c6400;

/// @notice The address of the Grouping Module.
IGroupingModule public immutable GROUPING_MODULE;
Expand Down Expand Up @@ -82,7 +81,7 @@ contract GroupingWorkflow is
licensingModule == address(0) ||
licenseRegistry == address(0) ||
pilTemplate == address(0)
) revert Errors.GroupingWorkflow__ZeroAddressParam();
) revert Errors.GroupingWorkflows__ZeroAddressParam();

GROUPING_MODULE = IGroupingModule(groupingModule);
GROUP_NFT = GroupNFT(groupNft);
Expand All @@ -93,16 +92,16 @@ contract GroupingWorkflow is
/// @dev Initializes the contract.
/// @param accessManager The address of the protocol access manager.
function initialize(address accessManager) external initializer {
if (accessManager == address(0)) revert Errors.GroupingWorkflow__ZeroAddressParam();
if (accessManager == address(0)) revert Errors.GroupingWorkflows__ZeroAddressParam();
__AccessManaged_init(accessManager);
__UUPSUpgradeable_init();
}

/// @dev Sets the NFT contract beacon address.
/// @param newNftContractBeacon The address of the new NFT contract beacon.
function setNftContractBeacon(address newNftContractBeacon) external restricted {
if (newNftContractBeacon == address(0)) revert Errors.GroupingWorkflow__ZeroAddressParam();
GroupingWorkflowStorage storage $ = _getGroupingWorkflowStorage();
if (newNftContractBeacon == address(0)) revert Errors.GroupingWorkflows__ZeroAddressParam();
GroupingWorkflowsStorage storage $ = _getGroupingWorkflowsStorage();
$.nftContractBeacon = newNftContractBeacon;
}

Expand Down Expand Up @@ -206,7 +205,7 @@ contract GroupingWorkflow is

/// @notice Register a group IP with a group reward pool, register Programmable IP License Terms,
/// attach it to the group IP, and add individual IPs to the group IP.
/// @dev ipIds must be have the same PIL terms as the group IP.
/// @dev ipIds must have the same PIL terms as the group IP.
/// @param groupPool The address of the group reward pool.
/// @param ipIds The IDs of the IPs to add to the newly registered group IP.
/// @param groupIpTerms The PIL terms to be registered and attached to the newly registered group IP.
Expand Down Expand Up @@ -236,10 +235,10 @@ contract GroupingWorkflow is
// Upgrade
//

/// @dev Returns the storage struct of GroupingWorkflow.
function _getGroupingWorkflowStorage() private pure returns (GroupingWorkflowStorage storage $) {
/// @dev Returns the storage struct of GroupingWorkflows.
function _getGroupingWorkflowsStorage() private pure returns (GroupingWorkflowsStorage storage $) {
assembly {
$.slot := GroupingWorkflowStorageLocation
$.slot := GroupingWorkflowsStorageLocation
}
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/SPGNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl
/// @dev The address of the SPG contract.
address public immutable SPG_ADDRESS;

///@dev The address of the GroupingWorkflow contract.
///@dev The address of the GroupingWorkflows contract.
address public immutable GROUPING_ADDRESS;

/// @notice Modifier to restrict access to the SPG contract.
Expand All @@ -42,11 +42,11 @@ contract SPGNFT is ISPGNFT, ERC721URIStorageUpgradeable, AccessControlUpgradeabl
}

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address spg, address groupingWorkflow) {
if (spg == address(0) || groupingWorkflow == address(0)) revert Errors.SPGNFT__ZeroAddressParam();
constructor(address spg, address groupingWorkflows) {
if (spg == address(0) || groupingWorkflows == address(0)) revert Errors.SPGNFT__ZeroAddressParam();

SPG_ADDRESS = spg;
GROUPING_ADDRESS = groupingWorkflow;
GROUPING_ADDRESS = groupingWorkflows;

_disableInitializers();
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/StoryProtocolGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ contract StoryProtocolGateway is
/// @param tokenId The ID of the NFT.
/// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP.
/// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module.
/// @return ipId The ID of the newly registered IP
/// @return ipId The ID of the newly registered IP.
function registerIp(
address nftContract,
uint256 tokenId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { PILTerms } from "@storyprotocol/core/interfaces/modules/licensing/IPILi

import { IStoryProtocolGateway as ISPG } from "../interfaces/IStoryProtocolGateway.sol";

/// @title Grouping Workflow Interface
interface IGroupingWorkflow {
/// @title Grouping Workflows Interface
interface IGroupingWorkflows {
/// @notice Mint an NFT from a SPGNFT collection, register it with metadata as an IP,
/// attach Programmable IP License Terms to the registered IP, and add it to a group IP.
/// @dev Caller must have the minter role for the provided SPG NFT.
Expand Down
4 changes: 2 additions & 2 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ library Errors {
/// @notice Caller is not one of the periphery contracts.
error SPGNFT__CallerNotPeripheryContract();

/// @notice Zero address provided as a param to the GroupingWorkflow.
error GroupingWorkflow__ZeroAddressParam();
/// @notice Zero address provided as a param to the GroupingWorkflows.
error GroupingWorkflows__ZeroAddressParam();
}
2 changes: 1 addition & 1 deletion contracts/lib/LicensingHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library LicensingHelper {
ILicensingModule(licensingModule).attachLicenseTerms(ipId, pilTemplate, licenseTermsId);
}

/// @dev Collects license tokens from the caller. Assumes SPG has permission to transfer the license tokens.
/// @dev Collects license tokens from the caller. Assumes the periphery contract has permission to transfer the license tokens.
/// @param licenseTokenIds The IDs of the license tokens to be collected.
/// @param licenseToken The address of the license token contract.
function collectLicenseTokens(uint256[] calldata licenseTokenIds, address licenseToken) internal {
Expand Down
6 changes: 3 additions & 3 deletions script/UpgradeSPGNFT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Script } from "forge-std/Script.sol";
import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";

import { StoryProtocolGateway } from "../contracts/StoryProtocolGateway.sol";
import { GroupingWorkflow } from "../contracts/GroupingWorkflow.sol";
import { GroupingWorkflows } from "../contracts/GroupingWorkflows.sol";
import { SPGNFT } from "../contracts/SPGNFT.sol";

import { StoryProtocolPeripheryAddressManager } from "./utils/StoryProtocolPeripheryAddressManager.sol";
Expand All @@ -20,7 +20,7 @@ contract UpgradeSPGNFT is Script, StoryProtocolPeripheryAddressManager, Broadcas
using StringUtil for uint256;

StoryProtocolGateway private spg;
GroupingWorkflow private groupingWorkflow;
GroupingWorkflows private groupingWorkflows;
SPGNFT private spgNftImpl;
UpgradeableBeacon private spgNftBeacon;

Expand Down Expand Up @@ -50,7 +50,7 @@ contract UpgradeSPGNFT is Script, StoryProtocolPeripheryAddressManager, Broadcas
_writeAddress("SPGNFTBeacon", address(spgNftBeacon));

_predeploy("SPGNFTImpl");
spgNftImpl = new SPGNFT(address(spg), address(groupingWorkflow));
spgNftImpl = new SPGNFT(address(spg), address(groupingWorkflows));
_postdeploy("SPGNFTImpl", address(spgNftImpl));
}

Expand Down
2 changes: 0 additions & 2 deletions script/utils/BroadcastManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pragma solidity ^0.8.23;

import { Script } from "forge-std/Script.sol";

import { StringUtil } from "./StringUtil.sol";

contract BroadcastManager is Script {
address public multisig;
address public deployer;
Expand Down
24 changes: 14 additions & 10 deletions test/GroupingWorkflow.t.sol → test/GroupingWorkflows.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ILicensingModule } from "@storyprotocol/core/interfaces/modules/licensi

import { IStoryProtocolGateway as ISPG } from "../contracts/interfaces/IStoryProtocolGateway.sol";

contract GroupingWorkflowTest is BaseTest {
contract GroupingWorkflowsTest is BaseTest {
address internal groupId;

function setUp() public override {
Expand Down Expand Up @@ -48,7 +48,7 @@ contract GroupingWorkflowTest is BaseTest {
_;
}

function test_SPG_mintAndRegisterIpAndAddToGroup()
function test_GroupingWorkflows_mintAndRegisterIpAndAttachPILTermsAndAddToGroup()
public
withCollection
whenCallerHasMinterRole
Expand All @@ -59,15 +59,15 @@ contract GroupingWorkflowTest is BaseTest {

(bytes memory sigAddToGroup, bytes32 expectedState, ) = _getSetPermissionSigForPeriphery({
ipId: groupId,
to: address(groupingWorkflow),
to: address(groupingWorkflows),
module: address(groupingModule),
selector: IGroupingModule.addIp.selector,
deadline: deadline,
state: IIPAccount(payable(groupId)).state(),
signerPk: alicePk
});

(address ipId, uint256 tokenId) = groupingWorkflow.mintAndRegisterIpAndAttachPILTermsAndAddToGroup({
(address ipId, uint256 tokenId) = groupingWorkflows.mintAndRegisterIpAndAttachPILTermsAndAddToGroup({
spgNftContract: address(nftContract),
groupId: groupId,
recipient: caller,
Expand All @@ -89,7 +89,7 @@ contract GroupingWorkflowTest is BaseTest {
assertEq(licenseTermsId, 1);
}

function test_SPG_registerIpAndAddToGroup()
function test_GroupingWorkflows_registerIpAndAttachPILTermsAndAddToGroup()
public
withCollection
whenCallerHasMinterRole
Expand All @@ -103,23 +103,23 @@ contract GroupingWorkflowTest is BaseTest {

(bytes memory sigMetadataAndAttach, , ) = _getSetBatchPermissionSigForPeriphery({
ipId: expectedIpId,
permissionList: _getMetadataAndAttachTermsPermissionList(expectedIpId, address(groupingWorkflow)),
permissionList: _getMetadataAndAttachTermsPermissionList(expectedIpId, address(groupingWorkflows)),
deadline: deadline,
state: bytes32(0),
signerPk: alicePk
});

(bytes memory sigAddToGroup, , ) = _getSetPermissionSigForPeriphery({
ipId: groupId,
to: address(groupingWorkflow),
to: address(groupingWorkflows),
module: address(groupingModule),
selector: IGroupingModule.addIp.selector,
deadline: deadline,
state: IIPAccount(payable(groupId)).state(),
signerPk: alicePk
});

address ipId = groupingWorkflow.registerIpAndAttachPILTermsAndAddToGroup({
address ipId = groupingWorkflows.registerIpAndAttachPILTermsAndAddToGroup({
nftContract: address(nftContract),
tokenId: tokenId,
groupId: groupId,
Expand All @@ -145,7 +145,11 @@ contract GroupingWorkflowTest is BaseTest {
assertEq(licenseTermsId, 1);
}

function test_SPG_registerGroupAndAddIps() public withCollection whenCallerHasMinterRole {
function test_GroupingWorkflows_registerGroupAndAttachPILTermsAndAddIps()
public
withCollection
whenCallerHasMinterRole
{
mockToken.mint(address(caller), 1000 * 10 * 10 ** mockToken.decimals());
mockToken.approve(address(nftContract), 1000 * 10 * 10 ** mockToken.decimals());

Expand All @@ -167,7 +171,7 @@ contract GroupingWorkflowTest is BaseTest {
}

uint256 groupLicenseTermsId;
(groupId, groupLicenseTermsId) = groupingWorkflow.registerGroupAndAttachPILTermsAndAddIps(
(groupId, groupLicenseTermsId) = groupingWorkflows.registerGroupAndAttachPILTermsAndAddIps(
address(rewardPool),
ipIds,
PILFlavors.nonCommercialSocialRemixing()
Expand Down
4 changes: 2 additions & 2 deletions test/SPGNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract SPGNFTTest is BaseTest {
}

function test_SPGNFT_initialize() public {
address spgNftImpl = address(new SPGNFT(address(spg), address(groupingWorkflow)));
address spgNftImpl = address(new SPGNFT(address(spg), address(groupingWorkflows)));
address NFT_CONTRACT_BEACON = address(new UpgradeableBeacon(spgNftImpl, deployer));
ISPGNFT anotherNftContract = ISPGNFT(address(new BeaconProxy(NFT_CONTRACT_BEACON, "")));

Expand All @@ -57,7 +57,7 @@ contract SPGNFTTest is BaseTest {
}

function test_SPGNFT_initialize_revert_zeroParams() public {
address spgNftImpl = address(new SPGNFT(address(spg), address(groupingWorkflow)));
address spgNftImpl = address(new SPGNFT(address(spg), address(groupingWorkflows)));
address NFT_CONTRACT_BEACON = address(new UpgradeableBeacon(spgNftImpl, deployer));
nftContract = ISPGNFT(address(new BeaconProxy(NFT_CONTRACT_BEACON, "")));

Expand Down
16 changes: 8 additions & 8 deletions test/utils/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { ICoreMetadataModule } from "@storyprotocol/core/interfaces/modules/meta

import { StoryProtocolGateway } from "../../contracts/StoryProtocolGateway.sol";
import { IStoryProtocolGateway as ISPG } from "../../contracts/interfaces/IStoryProtocolGateway.sol";
import { GroupingWorkflow } from "../../contracts/GroupingWorkflow.sol";
import { GroupingWorkflows } from "../../contracts/GroupingWorkflows.sol";
import { SPGNFT } from "../../contracts/SPGNFT.sol";
import { ISPGNFT } from "../../contracts/interfaces/ISPGNFT.sol";
import { TestProxyHelper } from "./TestProxyHelper.t.sol";
Expand Down Expand Up @@ -74,7 +74,7 @@ contract BaseTest is Test {
StoryProtocolGateway internal spg;
SPGNFT internal spgNftImpl;
UpgradeableBeacon internal spgNftBeacon;
GroupingWorkflow internal groupingWorkflow;
GroupingWorkflows internal groupingWorkflows;

MockERC20 internal mockToken;
MockIPGraph internal ipGraph = MockIPGraph(address(0x1A));
Expand Down Expand Up @@ -509,7 +509,7 @@ contract BaseTest is Test {

impl = address(0); // Make sure we don't deploy wrong impl
impl = address(
new GroupingWorkflow(
new GroupingWorkflows(
address(accessController),
address(coreMetadataModule),
address(groupingModule),
Expand All @@ -521,19 +521,19 @@ contract BaseTest is Test {
)
);

groupingWorkflow = GroupingWorkflow(
groupingWorkflows = GroupingWorkflows(
TestProxyHelper.deployUUPSProxy(
create3Deployer,
_getSalt(type(GroupingWorkflow).name),
_getSalt(type(GroupingWorkflows).name),
impl,
abi.encodeCall(GroupingWorkflow.initialize, address(protocolAccessManager))
abi.encodeCall(GroupingWorkflows.initialize, address(protocolAccessManager))
)
);

spgNftImpl = SPGNFT(
create3Deployer.deploy(
_getSalt(type(SPGNFT).name),
abi.encodePacked(type(SPGNFT).creationCode, abi.encode(address(spg), address(groupingWorkflow)))
abi.encodePacked(type(SPGNFT).creationCode, abi.encode(address(spg), address(groupingWorkflows)))
)
);

Expand All @@ -545,7 +545,7 @@ contract BaseTest is Test {
);

spg.setNftContractBeacon(address(spgNftBeacon));
groupingWorkflow.setNftContractBeacon(address(spgNftBeacon));
groupingWorkflows.setNftContractBeacon(address(spgNftBeacon));

// bytes4[] memory selectors = new bytes4[](1);
// selectors[0] = UUPSUpgradeable.upgradeToAndCall.selector;
Expand Down
Loading

0 comments on commit 341eb2d

Please sign in to comment.