Skip to content

Commit

Permalink
fix(contracts): OZ-L1-L07 Lack of Logs on Sensitive Actions (#623)
Browse files Browse the repository at this point in the history
Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
  • Loading branch information
zimpha and HAOYUatHZ committed Jul 20, 2023
1 parent f8ec59f commit ff4a9e1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 10 deletions.
65 changes: 56 additions & 9 deletions contracts/src/libraries/FeeVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,43 @@ pragma solidity ^0.8.0;
import {IL2ScrollMessenger} from "../L2/IL2ScrollMessenger.sol";
import {OwnableBase} from "./common/OwnableBase.sol";

// solhint-disable no-empty-blocks
// solhint-disable reason-string

/// @title FeeVault
/// @notice The FeeVault contract contains the basic logic for the various different vault contracts
/// used to hold fee revenue generated by the L2 system.
abstract contract FeeVault is OwnableBase {
/**********
* Events *
**********/

/// @notice Emits each time that a withdrawal occurs.
///
/// @param value Amount that was withdrawn (in wei).
/// @param to Address that the funds were sent to.
/// @param from Address that triggered the withdrawal.
event Withdrawal(uint256 value, address to, address from);

/// @notice Emits each time the owner updates the address of `messenger`.
/// @param oldMessenger The address of old messenger.
/// @param newMessenger The address of new messenger.
event UpdateMessenger(address indexed oldMessenger, address indexed newMessenger);

/// @notice Emits each time the owner updates the address of `recipient`.
/// @param oldRecipient The address of old recipient.
/// @param newRecipient The address of new recipient.
event UpdateRecipient(address indexed oldRecipient, address indexed newRecipient);

/// @notice Emits each time the owner updates the value of `minWithdrawAmount`.
/// @param oldMinWithdrawAmount The value of old `minWithdrawAmount`.
/// @param newMinWithdrawAmount The value of new `minWithdrawAmount`.
event UpdateMinWithdrawAmount(uint256 oldMinWithdrawAmount, uint256 newMinWithdrawAmount);

/*************
* Variables *
*************/

/// @notice Minimum balance before a withdrawal can be triggered.
uint256 public minWithdrawAmount;

Expand All @@ -51,6 +77,10 @@ abstract contract FeeVault is OwnableBase {
/// @notice Total amount of wei processed by the contract.
uint256 public totalProcessed;

/***************
* Constructor *
***************/

/// @param _owner The owner of the contract.
/// @param _recipient Wallet that will receive the fees on L1.
/// @param _minWithdrawalAmount Minimum balance before a withdrawal can be triggered.
Expand All @@ -65,6 +95,10 @@ abstract contract FeeVault is OwnableBase {
recipient = _recipient;
}

/*****************************
* Public Mutating Functions *
*****************************/

/// @notice Allow the contract to receive ETH.
receive() external payable {}

Expand Down Expand Up @@ -92,21 +126,34 @@ abstract contract FeeVault is OwnableBase {
);
}

/************************
* Restricted Functions *
************************/

/// @notice Update the address of messenger.
/// @param _messenger The address of messenger to update.
function updateMessenger(address _messenger) external onlyOwner {
messenger = _messenger;
/// @param _newMessenger The address of messenger to update.
function updateMessenger(address _newMessenger) external onlyOwner {
address _oldMessenger = messenger;
messenger = _newMessenger;

emit UpdateMessenger(_oldMessenger, _newMessenger);
}

/// @notice Update the address of recipient.
/// @param _recipient The address of recipient to update.
function updateRecipient(address _recipient) external onlyOwner {
recipient = _recipient;
/// @param _newRecipient The address of recipient to update.
function updateRecipient(address _newRecipient) external onlyOwner {
address _oldRecipient = recipient;
recipient = _newRecipient;

emit UpdateRecipient(_oldRecipient, _newRecipient);
}

/// @notice Update the minimum withdraw amount.
/// @param _minWithdrawAmount The minimum withdraw amount to update.
function updateMinWithdrawAmount(uint256 _minWithdrawAmount) external onlyOwner {
minWithdrawAmount = _minWithdrawAmount;
/// @param _newMinWithdrawAmount The minimum withdraw amount to update.
function updateMinWithdrawAmount(uint256 _newMinWithdrawAmount) external onlyOwner {
uint256 _oldMinWithdrawAmount = minWithdrawAmount;
minWithdrawAmount = _newMinWithdrawAmount;

emit UpdateMinWithdrawAmount(_oldMinWithdrawAmount, _newMinWithdrawAmount);
}
}
3 changes: 3 additions & 0 deletions contracts/src/libraries/token/IScrollStandardERC20Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
pragma solidity ^0.8.0;

interface IScrollStandardERC20Factory {
/// @notice Emitted when a l2 token is deployed.
/// @param _l1Token The address of the l1 token.
/// @param _l2Token The address of the l2 token.
event DeployToken(address indexed _l1Token, address indexed _l2Token);

/// @notice Compute the corresponding l2 token address given l1 token address.
Expand Down
6 changes: 5 additions & 1 deletion contracts/src/libraries/token/ScrollStandardERC20Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ contract ScrollStandardERC20Factory is Ownable, IScrollStandardERC20Factory {
function deployL2Token(address _gateway, address _l1Token) external onlyOwner returns (address) {
bytes32 _salt = _getSalt(_gateway, _l1Token);

return Clones.cloneDeterministic(implementation, _salt);
address _l2Token = Clones.cloneDeterministic(implementation, _salt);

emit DeployToken(_l1Token, _l2Token);

return _l2Token;
}

function _getSalt(address _gateway, address _l1Token) internal pure returns (bytes32) {
Expand Down

0 comments on commit ff4a9e1

Please sign in to comment.