fix: [P-15] processFollow() in FeeFollowModule reverts for zero currency and amount T-16817

This commit is contained in:
vicnaum
2023-10-13 18:22:14 +02:00
parent 2d33d113fe
commit 5a22a606da
2 changed files with 30 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;