Skip to content
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(protocol): use Ownable2StepUpgradeable for better security #16029

Merged
merged 5 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion packages/protocol/contracts/common/EssentialContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

pragma solidity 0.8.24;

import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "./AddressResolver.sol";
import "./OwnerUUPSUpgradable.sol";

abstract contract EssentialContract is OwnerUUPSUpgradable, AddressResolver {
abstract contract Essential1StepContract is OwnerUUPSUpgradable, AddressResolver {
uint256[50] private __gap;

/// @dev Modifier that ensures the caller is the owner or resolved address of a given name.
Expand All @@ -41,3 +42,21 @@ abstract contract EssentialContract is OwnerUUPSUpgradable, AddressResolver {
__Essential_init(address(0));
}
}

abstract contract EssentialContract is Essential1StepContract, Ownable2StepUpgradeable {
function transferOwnership(address newOwner)
public
virtual
override(Ownable2StepUpgradeable, OwnableUpgradeable)
{
Ownable2StepUpgradeable.transferOwnership(newOwner);
}

function _transferOwnership(address newOwner)
internal
virtual
override(Ownable2StepUpgradeable, OwnableUpgradeable)
{
Ownable2StepUpgradeable._transferOwnership(newOwner);
}
}
2 changes: 1 addition & 1 deletion packages/protocol/contracts/tokenvault/BaseVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "../libs/LibAddress.sol";
import "../libs/LibDeploy.sol";

abstract contract BaseVault is
EssentialContract,
Essential1StepContract,
IRecallableSender,
IMessageInvocable,
IERC165Upgradeable
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import "./LibBridgedToken.sol";
/// @title BridgedERC1155
/// @notice Contract for bridging ERC1155 tokens across different chains.
contract BridgedERC1155 is
EssentialContract,
Essential1StepContract,
IERC1155Upgradeable,
IERC1155MetadataURIUpgradeable,
ERC1155Upgradeable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "../common/EssentialContract.sol";
import "./IBridgedERC20.sol";

abstract contract BridgedERC20Base is EssentialContract, IBridgedERC20 {
abstract contract BridgedERC20Base is Essential1StepContract, IBridgedERC20 {
address public migratingAddress; // slot 1
bool public migratingInbound;
uint256[49] private __gap;
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "./LibBridgedToken.sol";

/// @title BridgedERC721
/// @notice Contract for bridging ERC721 tokens across different chains.
contract BridgedERC721 is EssentialContract, ERC721Upgradeable {
contract BridgedERC721 is Essential1StepContract, ERC721Upgradeable {
address public srcToken; // Address of the source token contract.
uint256 public srcChainId; // Source chain ID where the token originates.

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/common/EssentialContract.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import "../TaikoTest.sol";

contract Target1 is EssentialContract {
contract Target1 is Essential1StepContract {
uint256 public count;

function init() external initializer {
Expand Down
Loading