Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add array length matching check in internal library functions #181

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading