-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into initializers
- Loading branch information
Showing
24 changed files
with
358 additions
and
212 deletions.
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
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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
// Example of a custom proxy. | ||
// This contract is for testing only. | ||
|
||
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol"; | ||
import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol"; | ||
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol"; | ||
|
||
contract AccessManagedProxy is ERC1967Proxy { | ||
IAccessManager public immutable ACCESS_MANAGER; | ||
|
||
constructor(address implementation, bytes memory _data, IAccessManager manager) payable ERC1967Proxy(implementation, _data) { | ||
ACCESS_MANAGER = manager; | ||
} | ||
|
||
/** | ||
* @dev Checks with the ACCESS_MANAGER if msg.sender is authorized to call the current call's function, | ||
* and if so, delegates the current call to `implementation`. | ||
* | ||
* This function does not return to its internal call site, it will return directly to the external caller. | ||
*/ | ||
function _delegate(address implementation) internal virtual override { | ||
(bool immediate, ) = ACCESS_MANAGER.canCall(msg.sender, address(this), bytes4(msg.data[0:4])); | ||
if (!immediate) revert IAccessManaged.AccessManagedUnauthorized(msg.sender); | ||
super._delegate(implementation); | ||
} | ||
} |
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,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; | ||
|
||
// Example of a custom beacon proxy. | ||
// This contract is for testing only, it is not safe for use in production. | ||
|
||
contract CustomBeaconProxy is BeaconProxy { | ||
address private immutable _deployer; | ||
// The beacon that will be used on calls by the deployer address | ||
address private immutable _deployerBeacon; | ||
|
||
constructor(address beacon, bytes memory data, address deployerBeacon) payable BeaconProxy(beacon, data) { | ||
_deployer = msg.sender; | ||
_deployerBeacon = deployerBeacon; | ||
} | ||
|
||
function _getBeacon() internal view override returns (address) { | ||
if (msg.sender == _deployer) return _deployerBeacon; | ||
return super._getBeacon(); | ||
} | ||
} |
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.