Skip to content

fix(contracts): until parameter is not correctly set on UserPayment event #2268

@JuArce

Description

@JuArce

When emitting emit UserPayment(msg.sender, amount, block.timestamp, block.timestamp + paymentExpirationTimeSeconds);, it should emit until = newExpiration

    /**
     * @notice Accepts payments and validates they meet the minimum requirement.
     */
    receive() external payable {
        uint256 amount = msg.value;

        if (amount < amountToPayInWei) {
            revert InvalidDepositAmount(amount, amountToPayInWei);
        }

        if (activeSubscriptionsAmount >= subscriptionLimit) {
            revert SubscriptionLimitReached(subscriptionLimit);
        }

        if (subscribedAddresses[msg.sender] < block.timestamp) {
            // Subscription is inactive/expired: start a new period from now.
            subscribedAddresses[msg.sender] = block.timestamp + paymentExpirationTimeSeconds;
            ++activeSubscriptionsAmount;
        } else {
            // Subscription is still active: extend the current expiry by one period.
            subscribedAddresses[msg.sender] = subscribedAddresses[msg.sender] + paymentExpirationTimeSeconds;
        }

        uint256 newExpiration = subscribedAddresses[msg.sender];

        if (newExpiration - block.timestamp > maxSubscriptionTimeAhead) {
            revert SubscriptionTimeExceedsLimit(newExpiration, maxSubscriptionTimeAhead);
        }


        emit UserPayment(msg.sender, amount, block.timestamp, block.timestamp + paymentExpirationTimeSeconds);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions