mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-10 14:48:15 -05:00
fix: [P-15] processFollow() in FeeFollowModule reverts for zero currency and amount T-16817
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user