Skip to content

Commit

Permalink
feat: add event for setDepositLimit (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
benceharomi authored Oct 31, 2023
1 parent 48a0015 commit 5bbfd87
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions ethereum/contracts/common/AllowList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ contract AllowList is IAllowList, Ownable2Step {
function setDepositLimit(address _l1Token, bool _depositLimitation, uint256 _depositCap) external onlyOwner {
tokenDeposit[_l1Token].depositLimitation = _depositLimitation;
tokenDeposit[_l1Token].depositCap = _depositCap;
emit UpdateDepositLimit(_l1Token, _depositLimitation, _depositCap);
}

/// @dev Get deposit limit data of a token
Expand Down
3 changes: 3 additions & 0 deletions ethereum/contracts/common/interfaces/IAllowList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface IAllowList {
/// @notice Permission to call is changed
event UpdateCallPermission(address indexed caller, address indexed target, bytes4 indexed functionSig, bool status);

/// @notice Deposit limit of a token is changed
event UpdateDepositLimit(address indexed l1Token, bool depositLimitation, uint256 depositCap);

/// @notice Type of access to a specific contract includes three different modes
/// @param Closed No one has access to the contract
/// @param SpecialAccessOnly Any address with granted special access can interact with a contract (see `hasSpecialAccessToCall`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pragma solidity 0.8.20;

import {Vm} from "forge-std/Test.sol";
import {AccessModeTest} from "./_AccessMode_Shared.t.sol";
import {IAllowList} from "../../../../../../cache/solpp-generated-contracts/common/interfaces/IAllowList.sol";

Expand Down Expand Up @@ -31,4 +32,30 @@ contract DepositLimitTest is AccessModeTest {
assertEq(deposit.depositLimitation, false, "depositLimitation should be false");
assertEq(deposit.depositCap, 0, "depositCap should be 0");
}

function test_UpdateDepositLimitEvent() public {
vm.startPrank(owner);

vm.recordLogs();
allowList.setDepositLimit(l1token, true, 1000);
Vm.Log[] memory entries = vm.getRecordedLogs();

assertEq(entries.length, 1);
assertEq(entries[0].topics.length, 2);
assertEq(
entries[0].topics[0],
keccak256("UpdateDepositLimit(address,bool,uint256)"),
"received event should be correct"
);
assertEq(
entries[0].topics[1],
bytes32(uint256(uint160(l1token))),
"received l1Token address should be correct"
);
assertEq(
entries[0].data,
abi.encode(true, 1000),
"received depositLimitation and depositCap should be correct"
);
}
}

0 comments on commit 5bbfd87

Please sign in to comment.