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

fix: add onlyInitializing and _disableInitializers #1179

Merged
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
6 changes: 6 additions & 0 deletions packages/marketplace/contracts/exchange/Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ contract Exchange is Initializable, AccessControlUpgradeable, ExchangeCore, Tran
/// @return hash for EXCHANGE_ADMIN_ROLE
bytes32 public constant EXCHANGE_ADMIN_ROLE = keccak256("EXCHANGE_ADMIN_ROLE");

/// @dev this protects the implementation contract from being initialized.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// @notice Exchange contract initializer
/// @param admin the admin user that can grant/revoke roles, etc.
/// @param newTrustedForwarder address for trusted forwarder that will execute meta transactions
Expand Down
2 changes: 1 addition & 1 deletion packages/marketplace/contracts/exchange/ExchangeCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana
function __ExchangeCoreInitialize(
IOrderValidator newOrderValidatorAddress,
IAssetMatcher newAssetMatcher
) internal {
) internal onlyInitializing {
_setOrderValidatorContract(newOrderValidatorAddress);
_setAssetMatcherContract(newAssetMatcher);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/marketplace/contracts/exchange/OrderValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ contract OrderValidator is IOrderValidator, Initializable, EIP712Upgradeable, Wh

bytes4 internal constant MAGICVALUE = 0x1626ba7e;

/// @dev this protects the implementation contract from being initialized.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// @notice initializer for OrderValidator
/// @param newTsbOnly boolean to indicate that only The Sandbox tokens are accepted by the exchange contract
/// @param newPartners boolena to indicate that partner tokens are accepted by the exchange contract
Expand Down
6 changes: 6 additions & 0 deletions packages/marketplace/contracts/exchange/WhiteList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ contract WhiteList is IWhiteList, OwnableUpgradeable, AccessControlUpgradeable {
/// @param erc20List boolean indicating that there is a restriction for ERC20 tokens
event PermissionSetted(bool tsbOnly, bool partners, bool open, bool erc20List);

/// @dev this protects the implementation contract from being initialized.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// @notice initializer for WhiteList
/// @param newTsbOnly allows orders with The Sandbox token
/// @param newPartners allows orders with partner token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ contract RoyaltiesRegistry is IRoyaltiesProvider, OwnableUpgradeable {
uint256 internal constant ROYALTIES_TYPE_UNSUPPORTED_NONEXISTENT = 4;
uint256 internal constant ROYALTIES_TYPES_AMOUNT = 4;

/// @dev this protects the implementation contract from being initialized.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// @notice Royalties registry initializer
// solhint-disable-next-line func-name-mixedcase
function __RoyaltiesRegistry_init() external initializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ abstract contract TransferManager is ERC165Upgradeable, ITransferManager {
uint256 newProtocolFeeSecondary,
address newDefaultFeeReceiver,
IRoyaltiesProvider newRoyaltiesProvider
) internal {
) internal onlyInitializing {
__ERC165_init();
_setProtocolFee(newProtocolFeePrimary, newProtocolFeeSecondary);
_setRoyaltiesRegistry(newRoyaltiesProvider);
_setDefaultFeeReceiver(newDefaultFeeReceiver);
Expand Down
Loading