-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: branch 'main' into serdar/219-send-refactor
- Loading branch information
Showing
13 changed files
with
713 additions
and
31 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
Large diffs are not rendered by default.
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,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
interface IIBCPausableUpgradeableErrors { | ||
/// @notice Error code returned when caller is not the pauser | ||
error Unauthorized(); | ||
} |
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,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
interface IIBCPausableUpgradeable { | ||
/// @notice Returns the pauser address | ||
/// @return The pauser address | ||
function getPauser() external view returns (address); | ||
|
||
/// @notice Pauses the contract | ||
/// @dev The caller must be the pauser | ||
function pause() external; | ||
|
||
/// @notice Unpauses the contract | ||
/// @dev The caller must be the pauser | ||
function unpause() external; | ||
|
||
/// @notice Sets the pauser address | ||
/// @dev Must be authorized by this contract | ||
/// @dev This operation cannot be paused | ||
/// @param pauser The new pauser address | ||
function setPauser(address pauser) external; | ||
} |
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,79 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
import { IIBCPausableUpgradeableErrors } from "../errors/IIBCPausableUpgradeableErrors.sol"; | ||
import { IIBCPausableUpgradeable } from "../interfaces/IIBCPausableUpgradeable.sol"; | ||
import { ContextUpgradeable } from "@openzeppelin-upgradeable/utils/ContextUpgradeable.sol"; | ||
import { PausableUpgradeable } from "@openzeppelin-upgradeable/utils/PausableUpgradeable.sol"; | ||
|
||
/// @title IBC Pausable Upgradeable contract | ||
/// @notice This contract is an abstract contract for adding pausability to IBC contracts. | ||
abstract contract IBCPausableUpgradeable is | ||
IIBCPausableUpgradeableErrors, | ||
IIBCPausableUpgradeable, | ||
ContextUpgradeable, | ||
PausableUpgradeable | ||
{ | ||
/// @notice Storage of the IBCPausableUpgradeable contract | ||
/// @dev It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions when using with | ||
/// upgradeable contracts. | ||
/// @param _pauser The address that can pause and unpause the contract | ||
struct IBCPausableUpgradeableStorage { | ||
address _pauser; | ||
} | ||
|
||
/// @notice ERC-7201 slot for the IBCPausableUpgradeable storage | ||
/// @dev keccak256(abi.encode(uint256(keccak256("ibc.storage.IBCPausableUpgradeable")) - 1)) & | ||
/// ~bytes32(uint256(0xff)) | ||
bytes32 private constant IBCPAUSABLEUPGRADEABLE_STORAGE_SLOT = | ||
0x3cb0d659d6ec9ab9509297c9cf14e29ed0165d10590ef43eb31ba393e648af00; | ||
|
||
/** | ||
* @dev Initializes the contract in unpaused state. | ||
*/ | ||
function __IBCPausable_init(address pauser) internal onlyInitializing { | ||
__Pausable_init(); | ||
|
||
_getIBCPausableUpgradeableStorage()._pauser = pauser; | ||
} | ||
|
||
/// @inheritdoc IIBCPausableUpgradeable | ||
function getPauser() public view returns (address) { | ||
return _getIBCPausableUpgradeableStorage()._pauser; | ||
} | ||
|
||
/// @inheritdoc IIBCPausableUpgradeable | ||
function pause() external onlyPauser { | ||
_pause(); | ||
} | ||
|
||
/// @inheritdoc IIBCPausableUpgradeable | ||
function unpause() external onlyPauser { | ||
_unpause(); | ||
} | ||
|
||
/// @inheritdoc IIBCPausableUpgradeable | ||
function setPauser(address pauser) public { | ||
_authorizeSetPauser(pauser); | ||
_getIBCPausableUpgradeableStorage()._pauser = pauser; | ||
} | ||
|
||
/// @notice Authorizes the setting of a new pauser | ||
/// @param pauser The new address that can pause and unpause the contract | ||
/// @dev This function must be overridden to add authorization logic | ||
function _authorizeSetPauser(address pauser) internal virtual; | ||
|
||
/// @notice Returns the storage of the IBCPausableUpgradeable contract | ||
function _getIBCPausableUpgradeableStorage() internal pure returns (IBCPausableUpgradeableStorage storage $) { | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
$.slot := IBCPAUSABLEUPGRADEABLE_STORAGE_SLOT | ||
} | ||
} | ||
|
||
/// @notice Modifier to make a function callable only by the pauser | ||
modifier onlyPauser() { | ||
require(_msgSender() == getPauser(), Unauthorized()); | ||
_; | ||
} | ||
} |
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
Oops, something went wrong.