-
Notifications
You must be signed in to change notification settings - Fork 29
Updated OpenZeppelin to version 5.1.0 #109
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
f617a34
updated dependencies
aritkulova 2abbd20
specified initialOwner for __Ownable_init function
aritkulova 9a07b3f
MathUpgradeable lib -> Math lib
aritkulova ab45e91
created mock contract for ERC721Holder
aritkulova 986f89c
updated test's error handlers to catch custom errors
aritkulova 079f373
fixed typo in test
aritkulova fb146e2
Added custom TransparentUpgradeableProxy contract
aritkulova e2f8cad
Removed isContract()
aritkulova 40654bc
Fixed typo
aritkulova 157bb61
Cleaned up dependencies
aritkulova 8157d52
Dropped tests for isContract() check in Diamond
aritkulova 2c640f1
Removed unnecessary dependency
aritkulova f4b6501
Added solhint command to scripts
aritkulova 7cb5d08
Merge branch 'master' of https://github.com/dl-solarity/solidity-lib …
aritkulova f629e9b
Renamed TransparentUpgradeableProxy to avoid collisions
aritkulova a29c83e
Updated dependencies
aritkulova 5f260e0
Fixed package-lock
aritkulova e995cf5
Switched to custom errors in contracts (#113)
aritkulova a2fb96f
Added missed .withArgs() to error handlers
aritkulova ce09777
Updated .solhint config
KyrylR 6cebb56
Updated versions
KyrylR ff5c0ae
updated openzeppelin to 5.1.0
aritkulova 0d73294
review fixes: linting
aritkulova 8b48a26
renamed TransparentProxy to AdminableProxy
aritkulova 76342a6
moved IAdminableProxy to the interfaces;
aritkulova d0f13dd
switched from staticcall to call through interface in AdminableProxyU…
aritkulova 482efa6
updated dev dependencies
aritkulova d780e5d
downgraded types/chai and types/node
aritkulova 68b9f95
renamed transparent dir to adminable
aritkulova 0c9429c
placed Traversal lib into AvlTree file
aritkulova 8403147
erc721:
aritkulova a5d9922
erc20:
aritkulova 6de7262
linting
aritkulova 6375a28
linting
aritkulova 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; | ||
|
||
contract ERC721HolderMock is ERC721Holder {} |
This file contains hidden or 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
aritkulova marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
82 changes: 82 additions & 0 deletions
82
contracts/proxy/transparent/TransparentUpgradeableProxy.sol
This file contains hidden or 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,82 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.2/contracts/proxy/transparent/TransparentUpgradeableProxy.sol | ||
aritkulova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pragma solidity ^0.8.4; | ||
|
||
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; | ||
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import {IERC1967} from "@openzeppelin/contracts/interfaces/IERC1967.sol"; | ||
|
||
/** | ||
* @notice The proxies module | ||
* | ||
* Interface for TransparentUpgradeableProxy. | ||
**/ | ||
interface ITransparentUpgradeableProxy is IERC1967 { | ||
/** | ||
* @notice The function to upgrade the implementation contract with additional setup call if data is nonempty. | ||
*/ | ||
function upgradeToAndCall(address, bytes calldata) external payable; | ||
|
||
/** | ||
* @notice The function to return the current implementation address. | ||
*/ | ||
function implementation() external returns (address); | ||
} | ||
|
||
/** | ||
* @notice This contract implements a proxy that is upgradeable by an admin. | ||
* | ||
* The implementation of this contract is based on OpenZeppelin's TransparentUpgradeableProxy. | ||
* The main change is in the constructor. While the original contract deploys an instance of ProxyAdmin | ||
* for every proxy, this implementation simply sets the specified address as the admin. | ||
* Additionally, an implementation function has been added. | ||
* | ||
* For more information about proxy logic, please refer to the OpenZeppelin documentation. | ||
*/ | ||
contract TransparentUpgradeableProxy is ERC1967Proxy { | ||
address private immutable _admin; | ||
|
||
error ProxyDeniedAdminAccess(); | ||
|
||
constructor( | ||
address logic_, | ||
address admin_, | ||
bytes memory data_ | ||
) payable ERC1967Proxy(logic_, data_) { | ||
_admin = admin_; | ||
ERC1967Utils.changeAdmin(admin_); | ||
} | ||
|
||
function _fallback() internal virtual override { | ||
if (msg.sender == _admin) { | ||
bytes4 selector_ = msg.sig; | ||
|
||
if (selector_ == ITransparentUpgradeableProxy.upgradeToAndCall.selector) { | ||
_dispatchUpgradeToAndCall(); | ||
} else if (selector_ == ITransparentUpgradeableProxy.implementation.selector) { | ||
bytes memory returndata_ = _dispatchImplementation(); | ||
|
||
assembly { | ||
return(add(returndata_, 0x20), mload(returndata_)) | ||
} | ||
} else { | ||
revert ProxyDeniedAdminAccess(); | ||
} | ||
} else { | ||
super._fallback(); | ||
} | ||
} | ||
|
||
function _dispatchUpgradeToAndCall() private { | ||
(address newImplementation_, bytes memory data_) = abi.decode( | ||
msg.data[4:], | ||
(address, bytes) | ||
); | ||
ERC1967Utils.upgradeToAndCall(newImplementation_, data_); | ||
} | ||
|
||
function _dispatchImplementation() private view returns (bytes memory) { | ||
return abi.encode(_implementation()); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.