Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add event for setDepositLimit #72

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.17;

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"
);
}
}
Loading