Skip to content

Commit

Permalink
adding access control TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jul 3, 2024
1 parent 2b64c79 commit ea767f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/prototypes/evm/ERC20CustodyNew.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ contract ERC20CustodyNew is ReentrancyGuard{
}

// Withdraw is called by TSS address, it directly transfers the tokens to the destination address without contract call
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function withdraw(address token, address to, uint256 amount) external nonReentrant {
IERC20(token).safeTransfer(to, amount);

Expand All @@ -30,6 +32,8 @@ contract ERC20CustodyNew is ReentrancyGuard{

// WithdrawAndCall is called by TSS address, it transfers the tokens and call a contract
// For this, it passes through the Gateway contract, it transfers the tokens to the Gateway contract and then calls the contract
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function withdrawAndCall(address token, address to, uint256 amount, bytes calldata data) external nonReentrant {
// Transfer the tokens to the Gateway contract
IERC20(token).transfer(address(gateway), amount);
Expand Down
6 changes: 6 additions & 0 deletions contracts/prototypes/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ contract GatewayZEVM is Initializable, OwnableUpgradeable, UUPSUpgradeable {
}

// Deposit foreign coins into ZRC20
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function deposit(
address zrc20,
uint256 amount,
Expand All @@ -75,6 +77,8 @@ contract GatewayZEVM is Initializable, OwnableUpgradeable, UUPSUpgradeable {
}

// Execute user specified contract on ZEVM
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function execute(
zContext calldata context,
address zrc20,
Expand All @@ -88,6 +92,8 @@ contract GatewayZEVM is Initializable, OwnableUpgradeable, UUPSUpgradeable {
}

// Deposit foreign coins into ZRC20 and call user specified contract on ZEVM
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function depositAndCall(
zContext calldata context,
address zrc20,
Expand Down
8 changes: 8 additions & 0 deletions contracts/prototypes/zevm/ZRC20New.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ contract ZRC20New is IZRC20, IZRC20Metadata, ZRC20Errors {
* @param amount, amount to deposit.
* @return true/false if succeeded/failed.
*/
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function deposit(address to, uint256 amount) external override returns (bool) {
if (msg.sender != FUNGIBLE_MODULE_ADDRESS && msg.sender != SYSTEM_CONTRACT_ADDRESS && msg.sender != GATEWAY_CONTRACT_ADDRESS) revert InvalidSender();
_mint(to, amount);
Expand Down Expand Up @@ -273,6 +275,8 @@ contract ZRC20New is IZRC20, IZRC20Metadata, ZRC20Errors {
* @dev Updates system contract address. Can only be updated by the fungible module.
* @param addr, new system contract address.
*/
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function updateSystemContractAddress(address addr) external onlyFungible {
SYSTEM_CONTRACT_ADDRESS = addr;
emit UpdatedSystemContract(addr);
Expand All @@ -282,6 +286,8 @@ contract ZRC20New is IZRC20, IZRC20Metadata, ZRC20Errors {
* @dev Updates gas limit. Can only be updated by the fungible module.
* @param gasLimit, new gas limit.
*/
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function updateGasLimit(uint256 gasLimit) external onlyFungible {
GAS_LIMIT = gasLimit;
emit UpdatedGasLimit(gasLimit);
Expand All @@ -291,6 +297,8 @@ contract ZRC20New is IZRC20, IZRC20Metadata, ZRC20Errors {
* @dev Updates protocol flat fee. Can only be updated by the fungible module.
* @param protocolFlatFee, new protocol flat fee.
*/
// TODO: Finalize access control
// https://github.com/zeta-chain/protocol-contracts/issues/204
function updateProtocolFlatFee(uint256 protocolFlatFee) external onlyFungible {
PROTOCOL_FLAT_FEE = protocolFlatFee;
emit UpdatedProtocolFlatFee(protocolFlatFee);
Expand Down

0 comments on commit ea767f6

Please sign in to comment.