-
Notifications
You must be signed in to change notification settings - Fork 91
feat: Develop SingleRequestProxy Smart Contracts
#1453
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
Changes from 1 commit
e2567f4
c624474
917d472
d5e4728
0543092
2bd3495
19b5e40
c1d3a77
1376582
c2f55ee
bc922e8
8aef234
0769aa7
3bd9e38
ed429ae
d9a4484
a341ce1
10974b5
2cc82a0
bee1f58
aab6711
0c68eba
796f2b9
0482f6d
b8183f3
85fdc13
9033066
cd91ec2
f944199
c77c1eb
41e43b5
01c28d2
cfba1b9
7241e0c
4abe9e9
90b413f
c493758
06e015a
c778b17
b45607a
c58dfc0
9ee661a
0141d22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,4 +76,16 @@ contract ERC20SingleRequestProxy { | |
| bool success = SafeERC20.safeTransfer(token, payee, balance); | ||
| require(success, 'ERC20 rescue failed'); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Rescues any trapped funds by sending them to the payee | ||
| * @dev Can be called by anyone, but funds are always sent to the payee | ||
| */ | ||
| function rescueNativeFunds() external { | ||
| uint256 balance = address(this).balance; | ||
| require(balance > 0, 'No funds to rescue'); | ||
|
|
||
| (bool success, ) = payable(payee).call{value: balance}(''); | ||
| require(success, 'Rescue failed'); | ||
| } | ||
|
Comment on lines
+84
to
+90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Reentrancy Guard to The Add a reentrancy guard to this function to enhance security. Apply this diff to add the guard: function rescueNativeFunds() external {
+ require(!locked, "Reentrant call detected");
+ locked = true;
uint256 balance = address(this).balance;
require(balance > 0, 'No funds to rescue');
(bool success, ) = payable(payee).call{value: balance}('');
require(success, 'Rescue failed');
+ locked = false;
}
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |||||||||||||||||||||||||||||||
| pragma solidity 0.8.9; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import './interfaces/EthereumFeeProxy.sol'; | ||||||||||||||||||||||||||||||||
aimensahnoun marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; | ||||||||||||||||||||||||||||||||
| import './lib/SafeERC20.sol'; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * @title EthereumSingleRequestProxy | ||||||||||||||||||||||||||||||||
|
|
@@ -88,11 +90,25 @@ contract EthereumSingleRequestProxy { | |||||||||||||||||||||||||||||||
| * @notice Rescues any trapped funds by sending them to the payee | ||||||||||||||||||||||||||||||||
| * @dev Can be called by anyone, but funds are always sent to the payee | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| function rescueFunds() external nonReentrant { | ||||||||||||||||||||||||||||||||
| function rescueNativeFunds() external nonReentrant { | ||||||||||||||||||||||||||||||||
| uint256 balance = address(this).balance; | ||||||||||||||||||||||||||||||||
| require(balance > 0, 'No funds to rescue'); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| (bool success, ) = payable(payee).call{value: balance}(''); | ||||||||||||||||||||||||||||||||
| require(success, 'Rescue failed'); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * @notice Rescues any trapped ERC20 funds by sending them to the payee | ||||||||||||||||||||||||||||||||
| * @dev Can be called by anyone, but funds are always sent to the payee | ||||||||||||||||||||||||||||||||
| * @param _tokenAddress The address of the ERC20 token to rescue | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| function rescueERC20Funds(address _tokenAddress) external nonReentrant { | ||||||||||||||||||||||||||||||||
| require(_tokenAddress != address(0), 'Invalid token address'); | ||||||||||||||||||||||||||||||||
| IERC20 token = IERC20(_tokenAddress); | ||||||||||||||||||||||||||||||||
| uint256 balance = token.balanceOf(address(this)); | ||||||||||||||||||||||||||||||||
| require(balance > 0, 'No funds to rescue'); | ||||||||||||||||||||||||||||||||
| bool success = SafeERC20.safeTransfer(token, payee, balance); | ||||||||||||||||||||||||||||||||
| require(success, 'Rescue failed'); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+106
to
+113
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect usage of The Apply this diff to fix the code: - bool success = SafeERC20.safeTransfer(token, payee, balance);
- require(success, 'Rescue failed');
+ SafeERC20.safeTransfer(token, payee, balance);📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.