Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikelle committed Apr 18, 2024
1 parent af40c92 commit ef8e4d4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
28 changes: 28 additions & 0 deletions contracts/BidderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ contract BidderRegistry is IBidderRegistry, Ownable, ReentrancyGuard {
);
}

/**
* @dev Prepay for a specific window.
* @param window The window for which the prepay is being made.
*/
function prepayAllowanceForSpecificWindow(uint256 window) external payable {
require(msg.value >= minAllowance, "Insufficient prepay");

bidderRegistered[msg.sender] = true;
lockedFunds[msg.sender][window] += msg.value;

emit BidderRegistered(msg.sender, lockedFunds[msg.sender][window], window);
}

/**
* @dev Check the prepay of a bidder.
* @param bidder The address of the bidder.
Expand Down Expand Up @@ -284,6 +297,9 @@ contract BidderRegistry is IBidderRegistry, Ownable, ReentrancyGuard {
feePercent = newFeePercent;
}

/**
* @dev Withdraw funds to the fee recipient.
*/
function withdrawFeeRecipientAmount() external nonReentrant {
uint256 amount = feeRecipientAmount;
feeRecipientAmount = 0;
Expand All @@ -292,6 +308,10 @@ contract BidderRegistry is IBidderRegistry, Ownable, ReentrancyGuard {
require(successFee, "couldn't transfer to fee Recipient");
}

/**
* @dev Withdraw funds to the provider.
* @param provider The address of the provider.
*/
function withdrawProviderAmount(
address payable provider
) external nonReentrant {
Expand All @@ -303,6 +323,10 @@ contract BidderRegistry is IBidderRegistry, Ownable, ReentrancyGuard {
require(success, "couldn't transfer to provider");
}

/**
* @dev Withdraw funds to the bidder.
* @param bidder The address of the bidder.
*/
function withdrawBidderAmountFromWindow(
address payable bidder,
uint256 window
Expand All @@ -327,6 +351,10 @@ contract BidderRegistry is IBidderRegistry, Ownable, ReentrancyGuard {
emit BidderWithdrawal(bidder, window, amount);
}

/**
* @dev Withdraw protocol fee.
* @param bidder The address of the bidder.
*/
function withdrawProtocolFee(
address payable bidder
) external onlyOwner nonReentrant {
Expand Down
22 changes: 18 additions & 4 deletions contracts/BlockTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
*/
contract BlockTracker is Ownable {
/// @dev Event emitted when a new L1 block is tracked.
event NewL1Block(uint256 indexed blockNumber, address indexed winner, uint256 indexed window);
event NewL1Block(
uint256 indexed blockNumber,
address indexed winner,
uint256 indexed window
);

/// @dev Event emitted when a new window is created.
event NewWindow(uint256 indexed window);

/// @dev Event emitted when the number of blocks per window is updated.
event NewBlocksPerWindow(uint256 blocksPerWindow);

uint256 public currentWindow = 1;
uint256 public blocksPerWindow = 64;
uint256 public lastL1BlockNumber;
Expand Down Expand Up @@ -59,6 +66,8 @@ contract BlockTracker is Ownable {
*/
function setBlocksPerWindow(uint256 _blocksPerWindow) external onlyOwner {
blocksPerWindow = _blocksPerWindow;

emit NewBlocksPerWindow(blocksPerWindow);
}
/**
* @dev Returns the current window number.
Expand All @@ -73,7 +82,10 @@ contract BlockTracker is Ownable {
* @param _blockNumber The number of the new L1 block.
* @param _winner The address of the winner of the new L1 block.
*/
function recordL1Block(uint256 _blockNumber, address _winner) external onlyOwner {
function recordL1Block(
uint256 _blockNumber,
address _winner
) external onlyOwner {
lastL1BlockNumber = _blockNumber;
lastL1BlockWinner = _winner;
recordBlockWinner(_blockNumber, _winner);
Expand All @@ -98,7 +110,9 @@ contract BlockTracker is Ownable {
}

// Function to get the winner of a specific block
function getBlockWinner(uint256 blockNumber) external view returns (address) {
function getBlockWinner(
uint256 blockNumber
) external view returns (address) {
return blockWinners[blockNumber];
}

Expand All @@ -116,4 +130,4 @@ contract BlockTracker is Ownable {
receive() external payable {
revert("Invalid call");
}
}
}
3 changes: 3 additions & 0 deletions contracts/PreConfirmations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ contract PreConfCommitmentStore is Ownable {
bytes sharedSecretKey;
}

/// @dev Event to log successful commitment storage
event CommitmentStored(
bytes32 indexed commitmentIndex,
address bidder,
Expand All @@ -104,6 +105,7 @@ contract PreConfCommitmentStore is Ownable {
bytes sharedSecretKey
);

/// @dev Struct for all the information around encrypted preconfirmations commitment
struct EncrPreConfCommitment {
bool commitmentUsed;
address commiter;
Expand All @@ -112,6 +114,7 @@ contract PreConfCommitmentStore is Ownable {
uint256 blockCommitedAt;
}

/// @dev Event to log successful encrypted commitment storage
event EncryptedCommitmentStored(
bytes32 indexed commitmentIndex,
address commiter,
Expand Down
4 changes: 4 additions & 0 deletions contracts/ProviderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ contract ProviderRegistry is IProviderRegistry, Ownable, ReentrancyGuard {
require(success, "Couldn't transfer to bidder");
}

/**
* @dev Withdraw staked amount for the provider.
* @param provider The address of the provider.
*/
function withdrawStakedAmount(
address payable provider
) external nonReentrant {
Expand Down

0 comments on commit ef8e4d4

Please sign in to comment.