{
    "Function": "commitPayment",
    "File": "src/contracts/middleware/PaymentManager.sol",
    "Parent Contracts": [
        "src/contracts/permissions/Pausable.sol",
        "src/contracts/interfaces/IPausable.sol",
        "src/contracts/interfaces/IPaymentManager.sol",
        "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"
    ],
    "High-Level Calls": [
        "IQuorumRegistry",
        "SafeERC20",
        "IQuorumRegistry"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "onlyWhenNotPaused",
        "_taskNumber"
    ],
    "Library Calls": [
        "safeTransferFrom"
    ],
    "Low-Level Calls": [],
    "Code": "function commitPayment(uint32 toTaskNumber, uint96 amount) external onlyWhenNotPaused(PAUSED_NEW_PAYMENT_COMMIT) {\n        // only active operators can call\n        require(\n            registry.isActiveOperator(msg.sender),\n            \"PaymentManager.commitPayment: Only registered operators can call this function\"\n        );\n\n        require(toTaskNumber <= _taskNumber(), \"PaymentManager.commitPayment: Cannot claim future payments\");\n\n        // can only claim for a payment after redeeming the last payment\n        require(\n            operatorToPayment[msg.sender].status == PaymentStatus.REDEEMED,\n            \"PaymentManager.commitPayment: Require last payment is redeemed\"\n        );\n\n        // operator puts up tokens which can be slashed in case of wrongful payment claim\n        paymentChallengeToken.safeTransferFrom(msg.sender, address(this), paymentChallengeAmount);\n\n        // recording payment claims for the operator\n        uint32 fromTaskNumber;\n\n        // calculate the UTC timestamp at which the payment claim will be optimistically confirmed\n        uint32 confirmAt = uint32(block.timestamp + paymentFraudproofInterval);\n\n        /**\n         * @notice For the special case of this being the first payment that is being claimed by the operator,\n         * the operator must be claiming payment starting from when they registered.\n         */\n        if (operatorToPayment[msg.sender].fromTaskNumber == 0) {\n            // get the taskNumber when the operator registered\n            fromTaskNumber = registry.getFromTaskNumberForOperator(msg.sender);\n        } else {\n            // you have to redeem starting from the last task you previously redeemed up to\n            fromTaskNumber = operatorToPayment[msg.sender].toTaskNumber;\n        }\n\n        require(fromTaskNumber < toTaskNumber, \"invalid payment range\");\n\n        // update the record for the commitment to payment made by the operator\n        operatorToPayment[msg.sender] = Payment(\n            fromTaskNumber,\n            toTaskNumber,\n            confirmAt,\n            amount,\n            // set payment status as 1: committed\n            PaymentStatus.COMMITTED,\n            // storing guarantee amount deposited\n            paymentChallengeAmount\n        );\n\n        emit PaymentCommit(msg.sender, fromTaskNumber, toTaskNumber, amount);\n    }"
}