From b91d35b79b45d217513b71225ad21651f94e4304 Mon Sep 17 00:00:00 2001 From: Jmunoz Date: Thu, 25 Jan 2024 13:14:24 -0300 Subject: [PATCH] Add IAllowList interface --- .../bridge/interfaces/IAllowList.sol | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 l1-contracts/contracts/bridge/interfaces/IAllowList.sol diff --git a/l1-contracts/contracts/bridge/interfaces/IAllowList.sol b/l1-contracts/contracts/bridge/interfaces/IAllowList.sol new file mode 100644 index 0000000000..1cd1462d5f --- /dev/null +++ b/l1-contracts/contracts/bridge/interfaces/IAllowList.sol @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.20; + +interface IAllowList { + /*////////////////////////////////////////////////////////////// + EVENTS + //////////////////////////////////////////////////////////////*/ + + /// @notice Access mode of target contract is changed + event UpdateAccessMode(address indexed target, AccessMode previousMode, AccessMode newMode); + + /// @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`) + /// @param Public Everyone can interact with a contract + enum AccessMode { + Closed, + SpecialAccessOnly, + Public + } + + /// @dev A struct that contains deposit limit data of a token + /// @param depositLimitation Whether any deposit limitation is placed or not + /// @param depositCap The maximum amount that can be deposited. + struct Deposit { + bool depositLimitation; + uint256 depositCap; + } + + /*////////////////////////////////////////////////////////////// + GETTERS + //////////////////////////////////////////////////////////////*/ + + function getAccessMode(address _target) external view returns (AccessMode); + + function hasSpecialAccessToCall(address _caller, address _target, bytes4 _functionSig) external view returns (bool); + + function canCall(address _caller, address _target, bytes4 _functionSig) external view returns (bool); + + function getTokenDepositLimitData(address _l1Token) external view returns (Deposit memory); + + /*////////////////////////////////////////////////////////////// + ALLOW LIST LOGIC + //////////////////////////////////////////////////////////////*/ + + function setBatchAccessMode(address[] calldata _targets, AccessMode[] calldata _accessMode) external; + + function setAccessMode(address _target, AccessMode _accessMode) external; + + function setBatchPermissionToCall( + address[] calldata _callers, + address[] calldata _targets, + bytes4[] calldata _functionSigs, + bool[] calldata _enables + ) external; + + function setPermissionToCall(address _caller, address _target, bytes4 _functionSig, bool _enable) external; + + /*////////////////////////////////////////////////////////////// + DEPOSIT LIMIT LOGIC + //////////////////////////////////////////////////////////////*/ + + function setDepositLimit(address _l1Token, bool _depositLimitation, uint256 _depositCap) external; +}