-
Notifications
You must be signed in to change notification settings - Fork 2
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
pauseUntil
tested, coded, documented
#57
base: master
Are you sure you want to change the base?
pauseUntil
tested, coded, documented
#57
Conversation
function pause() external { | ||
_pause(); | ||
} | ||
|
||
function unpause() external { | ||
_unpause(); | ||
} | ||
|
||
function pauseUntil(uint256 duration) external { | ||
_pauseUntil(uint48(duration)); | ||
} | ||
|
||
function getPausedUntilDeadline() external view returns (uint256) { | ||
return _unpauseDeadline(); | ||
} | ||
|
||
function getPausedUntilDeadlineAndTimestamp() external view returns (uint256, uint256) { | ||
return (_unpauseDeadline(), clock()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions to expose internal functions are not necessary since we compile exposed contracts. To deploy the exposed contract, append a dollar sign to the contract name (like $Pausable
). The exposed contract has all the internal functions exposed externally with dollar signs prepended to the function names.
@@ -0,0 +1,34 @@ | |||
// SPDX-License-Identifier: MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this contract is necessary. We can either have the default values in the implementation (virtual so consumers can specify if they want). Or we can leave the choice to the user.
@@ -0,0 +1,201 @@ | |||
// SPDX-License-Identifier: MIT | |||
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be removed--it will be added automatically if necessary.
* @dev Clock is used here for time checkings on pauses with defined end-date. | ||
* | ||
* @dev IERC6372 implementation of a clock() based on native `block.timestamp`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't believe there can be 2 dev tags
As discussed in this issue on the official OpenZeppelin repository, this PR introduces a refactor of the
Pausable.sol
contract to implement apauseUntil(uint48 deadline)
functionality.Changes
1.
Pausable
ContractpauseUntil(uint48 unpauseDeadline)
functionality.ERC6372
in mind.Pausable
versions who independently implemented bothERC6372
andPausable
(e.g., viaIERC5805
) might face challenges if different time measurements are needed for pausing and other features.Pausable
contract implementingIERC5805
might use different time units for pausing and voting.2. New Directory Structure
utils/pausability
to accommodate the refactor:Pausable.sol
: General implementation ofPausable
without a specific time measurement tool.DefaultPausable.sol
: A default implementation ofPausable
usingERC6372
withblock.timestamp
as the time unit.3.
PausableMock
UpdatespauseUntil(uint48 deadline)
function._unpauseDeadline()
.4. Unit Tests
pauseUntil()
functionality:pause() -> pauseUntil()
pauseUntil() -> pause()
(before and after the deadline)pauseUntil() -> unpause()
(before and after the deadline)pauseUntil() -> pauseUntil()
(before and after the previous deadline)