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

fix: Add nonReentrant to ERC20Custody #93

Merged
merged 2 commits into from
Oct 31, 2023
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
12 changes: 9 additions & 3 deletions contracts/evm/ERC20Custody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ pragma solidity 0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

/// @title ERC20Custody.
/// @notice ERC20Custody for depositing ERC20 assets into ZetaChain and making operations with them.
contract ERC20Custody {
contract ERC20Custody is ReentrancyGuard {
using SafeERC20 for IERC20;

error NotWhitelisted();
Expand Down Expand Up @@ -161,7 +162,12 @@ contract ERC20Custody {
* @param amount, asset amount.
* @param message, bytes message or encoded zetechain call.
*/
function deposit(bytes calldata recipient, IERC20 asset, uint256 amount, bytes calldata message) external {
function deposit(
bytes calldata recipient,
IERC20 asset,
uint256 amount,
bytes calldata message
) external nonReentrant {
if (paused) {
revert IsPaused();
}
Expand All @@ -184,7 +190,7 @@ contract ERC20Custody {
* @param asset, ERC20 asset.
* @param amount, asset amount.
*/
function withdraw(address recipient, IERC20 asset, uint256 amount) external onlyTSS {
function withdraw(address recipient, IERC20 asset, uint256 amount) external nonReentrant onlyTSS {
if (paused) {
revert IsPaused();
}
Expand Down
Loading
Loading