-
Notifications
You must be signed in to change notification settings - Fork 56
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: Use @openzeppelin/[email protected] contracts in contracts we can upgrade #598
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a484de3
feat: Use @openzeppelin/[email protected] contracts in contracts we can u…
nicholaspai 5120e1a
Update MultiCallerUpgradeable.t.sol
nicholaspai f8437f3
fix test
nicholaspai 23acc47
Merge branch 'master' into npai/openzeppelin5
nicholaspai 9beefb4
Update DonationBox.sol
nicholaspai f47e6e9
Merge branch 'master' into npai/openzeppelin5
nicholaspai e46ba07
Update DonationBox.sol
nicholaspai 960dbd2
Merge branch 'master' into npai/openzeppelin5
nicholaspai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | |
* @custom:security-contact [email protected] | ||
*/ | ||
contract Ethereum_SpokePool is SpokePool, OwnableUpgradeable { | ||
using SafeERC20Upgradeable for IERC20Upgradeable; | ||
using SafeERC20 for IERC20; | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor( | ||
|
@@ -35,7 +35,7 @@ contract Ethereum_SpokePool is SpokePool, OwnableUpgradeable { | |
**************************************/ | ||
|
||
function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal override { | ||
IERC20Upgradeable(l2TokenAddress).safeTransfer(hubPool, amountToReturn); | ||
IERC20(l2TokenAddress).safeTransfer(hubPool, amountToReturn); | ||
} | ||
|
||
// The SpokePool deployed to the same network as the HubPool must be owned by the HubPool. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ pragma solidity ^0.8.0; | |
import "./Lockable.sol"; | ||
import "./external/interfaces/WETH9Interface.sol"; | ||
|
||
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; | ||
import "@openzeppelin/contracts5/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts5/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
// Polygon Registry contract that stores their addresses. | ||
interface PolygonRegistry { | ||
|
@@ -18,7 +18,7 @@ interface PolygonERC20Predicate { | |
} | ||
|
||
// ERC20s (on polygon) compatible with polygon's bridge have a withdraw method. | ||
interface PolygonIERC20Upgradeable is IERC20Upgradeable { | ||
interface PolygonIERC20Upgradeable is IERC20 { | ||
function withdraw(uint256 amount) external; | ||
} | ||
|
||
|
@@ -40,8 +40,8 @@ interface MaticToken { | |
* @custom:security-contact [email protected] | ||
*/ | ||
contract PolygonTokenBridger is Lockable { | ||
using SafeERC20Upgradeable for PolygonIERC20Upgradeable; | ||
using SafeERC20Upgradeable for IERC20Upgradeable; | ||
using SafeERC20 for PolygonIERC20Upgradeable; | ||
using SafeERC20 for IERC20; | ||
|
||
// Gas token for Polygon. | ||
MaticToken public constant MATIC = MaticToken(0x0000000000000000000000000000000000001010); | ||
|
@@ -121,7 +121,7 @@ contract PolygonTokenBridger is Lockable { | |
* @notice Called by someone to send tokens to the destination, which should be set to the HubPool. | ||
* @param token Token to send to destination. | ||
*/ | ||
function retrieve(IERC20Upgradeable token) public nonReentrant onlyChainId(l1ChainId) { | ||
function retrieve(IERC20 token) public nonReentrant onlyChainId(l1ChainId) { | ||
if (address(token) == address(l1Weth)) { | ||
// For WETH, there is a pre-deposit step to ensure any ETH that has been sent to the contract is captured. | ||
//slither-disable-next-line arbitrary-send-eth | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ interface IFxMessageProcessor { | |
* @custom:security-contact [email protected] | ||
*/ | ||
contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter { | ||
using SafeERC20Upgradeable for PolygonIERC20Upgradeable; | ||
using SafeERC20 for PolygonIERC20Upgradeable; | ||
|
||
// Address of FxChild which sends and receives messages to and from L1. | ||
address public fxChild; | ||
|
@@ -241,10 +241,7 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter | |
if (_isCCTPEnabled() && l2TokenAddress == address(usdcToken)) { | ||
_transferUsdc(hubPool, amountToReturn); | ||
} else { | ||
PolygonIERC20Upgradeable(l2TokenAddress).safeIncreaseAllowance( | ||
address(polygonTokenBridger), | ||
amountToReturn | ||
); | ||
PolygonIERC20Upgradeable(l2TokenAddress).forceApprove(address(polygonTokenBridger), amountToReturn); | ||
// Note: WrappedNativeToken is WMATIC on matic, so this tells the tokenbridger that this is an unwrappable native token. | ||
polygonTokenBridger.send(PolygonIERC20Upgradeable(l2TokenAddress), amountToReturn); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ interface IL2GatewayRouterExtended is IL2GatewayRouter { | |
* @custom:security-contact [email protected] | ||
*/ | ||
contract Scroll_SpokePool is SpokePool { | ||
using SafeERC20Upgradeable for IERC20Upgradeable; | ||
using SafeERC20 for IERC20; | ||
|
||
/** | ||
* @notice The address of the official l2GatewayRouter contract for Scroll for bridging tokens from L2 -> L1 | ||
|
@@ -99,7 +99,7 @@ contract Scroll_SpokePool is SpokePool { | |
// Tokens with a custom ERC20 gateway require an approval in order to withdraw. | ||
address erc20Gateway = l2GatewayRouter.getERC20Gateway(l2TokenAddress); | ||
if (erc20Gateway != l2GatewayRouter.defaultERC20Gateway()) { | ||
IERC20Upgradeable(l2TokenAddress).safeIncreaseAllowance(erc20Gateway, amountToReturn); | ||
IERC20(l2TokenAddress).forceApprove(erc20Gateway, amountToReturn); | ||
} | ||
|
||
// The scroll bridge handles arbitrary ERC20 tokens and is mindful of the official WETH address on-chain. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
// NOTE: Linea and Arbitrum only support 0.8.19, so keep this contract at 19 so create2 addressses for all chains are | ||
// the same. | ||
pragma solidity ^0.8.19; | ||
|
||
import "@openzeppelin/contracts/utils/Address.sol"; | ||
import "./interfaces/V3SpokePoolInterface.sol"; | ||
|
||
/** | ||
|
@@ -13,8 +14,6 @@ import "./interfaces/V3SpokePoolInterface.sol"; | |
* @custom:security-contact [email protected] | ||
*/ | ||
contract SpokePoolVerifier { | ||
using Address for address; | ||
|
||
error InvalidMsgValue(); | ||
error InvalidSpokePool(); | ||
|
||
|
@@ -54,7 +53,7 @@ contract SpokePoolVerifier { | |
bytes memory message | ||
) external payable { | ||
if (msg.value != inputAmount) revert InvalidMsgValue(); | ||
if (!address(spokePool).isContract()) revert InvalidSpokePool(); | ||
if (address(spokePool).code.length == 0) revert InvalidSpokePool(); | ||
// Set msg.sender as the depositor so that msg.sender can speed up the deposit. | ||
spokePool.depositV3{ value: msg.value }( | ||
msg.sender, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be =0.8.19?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that's right