generated from defi-wonderland/solidity-foundry-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 6
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: admin cant interact with usdc implementation #45
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; | ||
import {IUSDC} from 'interfaces/external/IUSDC.sol'; | ||
|
||
contract FallbackProxyAdmin is Ownable { | ||
/// @notice USDC address | ||
address public immutable USDC; | ||
|
||
/** | ||
* @notice Construct the FallbackProxyAdmin contract | ||
*/ | ||
constructor(address _usdc) Ownable(msg.sender) { | ||
USDC = _usdc; | ||
} | ||
|
||
/** | ||
* @notice Changes the admin of the USDC proxy | ||
* @param newAdmin Address to transfer proxy administration to | ||
* @dev Owner should always be the L2 Adapter | ||
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. here |
||
* @dev USDC admin cant interact proxy with implementation so we use this contract as the middleman | ||
*/ | ||
function changeAdmin(address newAdmin) external onlyOwner { | ||
IUSDC(USDC).changeAdmin(newAdmin); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {IntegrationBase} from './IntegrationBase.sol'; | ||
import {AddressAliasHelper} from 'test/utils/AddressAliasHelper.sol'; | ||
|
||
contract Integration_Bridging is IntegrationBase { | ||
/** | ||
* @notice Test the bridging process from L1 -> L2 | ||
*/ | ||
function test_bridgeFromL1() public { | ||
vm.selectFork(mainnet); | ||
|
||
uint256 _amount = 1e18; | ||
uint32 _minGasLimit = 1_000_000; | ||
|
||
// Deal doesnt work with proxies | ||
vm.startPrank(MAINNET_USDC.masterMinter()); | ||
MAINNET_USDC.configureMinter(MAINNET_USDC.masterMinter(), type(uint256).max); | ||
MAINNET_USDC.mint(_user, _amount); | ||
vm.stopPrank(); | ||
|
||
vm.startPrank(_user); | ||
MAINNET_USDC.approve(address(l1Adapter), _amount); | ||
l1Adapter.sendMessage(_user, _amount, _minGasLimit); | ||
vm.stopPrank(); | ||
|
||
assertEq(MAINNET_USDC.balanceOf(_user), 0); | ||
assertEq(MAINNET_USDC.balanceOf(address(l1Adapter)), _amount); | ||
|
||
vm.selectFork(optimism); | ||
uint256 _messageNonce = L2_MESSENGER.messageNonce(); | ||
|
||
vm.startPrank(AddressAliasHelper.applyL1ToL2Alias(address(OPTIMISM_L1_MESSENGER))); | ||
L2_MESSENGER.relayMessage( | ||
_messageNonce + 1, | ||
address(l1Adapter), | ||
address(l2Adapter), | ||
0, | ||
1_000_000, | ||
abi.encodeWithSignature('receiveMessage(address,uint256)', _user, _amount) | ||
); | ||
vm.stopPrank(); | ||
|
||
assertEq(bridgedUSDC.balanceOf(address(_user)), _amount); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
pragma solidity ^0.8.25; | ||
|
||
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; | ||
|
||
import {FallbackProxyAdmin} from 'contracts/utils/FallbackProxyAdmin.sol'; | ||
import {Helpers} from 'test/utils/Helpers.sol'; | ||
|
||
abstract contract Base is Helpers { | ||
address internal _usdc = makeAddr('usdc'); | ||
address internal _owner = makeAddr('owner'); | ||
|
||
FallbackProxyAdmin public admin; | ||
|
||
function setUp() public virtual { | ||
vm.prank(_owner); | ||
admin = new FallbackProxyAdmin(_usdc); | ||
} | ||
} | ||
|
||
contract FallbackProxyAdmin_Unit_ChangeAdmin is Base { | ||
function test_revertIfNotOwner(address _newOwner) public { | ||
vm.assume(_newOwner != _owner); | ||
|
||
vm.prank(_newOwner); | ||
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, _newOwner)); | ||
admin.changeAdmin(_newOwner); | ||
} | ||
|
||
function test_changeAdmin(address _newOwner) public { | ||
vm.assume(_newOwner != _owner); | ||
|
||
_mockAndExpect(address(_usdc), abi.encodeWithSignature('changeAdmin(address)', _newOwner), abi.encode()); | ||
vm.prank(_owner); | ||
admin.changeAdmin(_newOwner); | ||
} | ||
} |
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.
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.
here