diff --git a/contracts/modules/follow/FeeFollowModule.sol b/contracts/modules/follow/FeeFollowModule.sol index b605d2b..b4e7ed0 100644 --- a/contracts/modules/follow/FeeFollowModule.sol +++ b/contracts/modules/follow/FeeFollowModule.sol @@ -81,8 +81,14 @@ contract FeeFollowModule is FeeModuleBase, HubRestricted, IFollowModule { if (followTokenId == 0) { uint256 amount = _feeConfig[targetProfileId].amount; address currency = _feeConfig[targetProfileId].currency; + _validateDataIsExpected(data, currency, amount); + if (amount == 0 || currency == address(0)) { + // If the amount is zero, we don't charge anything. + return ''; + } + (address treasury, uint16 treasuryFee) = _treasuryData(); address recipient = _feeConfig[targetProfileId].recipient; uint256 treasuryAmount = (amount * treasuryFee) / BPS_MAX; diff --git a/test/modules/follow/FeeFollowModule.t.sol b/test/modules/follow/FeeFollowModule.t.sol index 3cd902c..7c69ff4 100644 --- a/test/modules/follow/FeeFollowModule.t.sol +++ b/test/modules/follow/FeeFollowModule.t.sol @@ -174,6 +174,30 @@ contract FeeFollowModuleTest is BaseTest { ); } + function testCanStillProcessFollow_ZeroCurrency( + uint256 followerProfileId, + uint256 targetProfileId, + address recipient, + address transactionExecutor + ) public { + vm.assume(followerProfileId != 0); + vm.assume(targetProfileId != 0); + vm.assume(transactionExecutor != address(0)); + + FeeConfig memory feeConfig = FeeConfig({currency: address(0), amount: 0, recipient: recipient}); + vm.prank(address(hub)); + feeFollowModule.initializeFollowModule(targetProfileId, address(0), abi.encode(feeConfig)); + + vm.prank(address(hub)); + feeFollowModule.processFollow( + followerProfileId, + 0, + transactionExecutor, + targetProfileId, + abi.encode(address(0), 0) // @audit-info currency, amount + ); + } + struct Balances { uint256 treasury; uint256 follower;