Skip to content

Commit

Permalink
fix: add array length matching check
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsadface committed Feb 11, 2025
1 parent 7e84f1b commit 6ff52d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions contracts/lib/LicensingHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { WorkflowStructs } from "./WorkflowStructs.sol";
library LicensingHelper {
using SafeERC20 for IERC20;

/// @notice Error for when the length of parent IP IDs and license terms IDs mismatch.
error LicensingHelper__ParentIpIdsAndLicenseTermsIdsMismatch();

/// @notice Registers multiple PIL terms and attaches them to the given IP and sets their licensing configurations.
/// @param ipId The ID of the IP.
/// @param licenseTermsData The PIL terms and licensing configuration data to be attached to the IP.
Expand Down Expand Up @@ -208,6 +211,9 @@ library LicensingHelper {
address[] memory parentIpIds,
uint256[] memory licenseTermsIds
) private view returns (uint256 totalMintFee) {
if (parentIpIds.length != licenseTermsIds.length)
revert LicensingHelper__ParentIpIdsAndLicenseTermsIdsMismatch();

uint256 mintFee;

for (uint256 i = 0; i < parentIpIds.length; i++) {
Expand Down
6 changes: 5 additions & 1 deletion contracts/lib/PermissionHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { WorkflowStructs } from "./WorkflowStructs.sol";
/// @title Periphery Permission Helper Library
/// @notice Library for all permissions related helper functions for Periphery contracts.
library PermissionHelper {
/// @notice Error for when the length of modules and selectors mismatch.
error PermissionHelper__ModulesAndSelectorsMismatch();

/// @dev Sets transient permission via signature to allow this contract to interact with the Licensing Module on behalf of the
/// provided IP Account.
/// @param ipId The ID of the IP.
Expand Down Expand Up @@ -55,7 +58,8 @@ library PermissionHelper {
bytes4[] memory selectors,
WorkflowStructs.SignatureData calldata sigData
) internal {
// assumes modules and selectors must have a 1:1 mapping
if (modules.length != selectors.length) revert PermissionHelper__ModulesAndSelectorsMismatch();

AccessPermission.Permission[] memory permissionList = new AccessPermission.Permission[](modules.length);
for (uint256 i = 0; i < modules.length; i++) {
permissionList[i] = AccessPermission.Permission({
Expand Down

0 comments on commit 6ff52d1

Please sign in to comment.