-
Notifications
You must be signed in to change notification settings - Fork 6
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/caveat test rebase #46
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
31f8e99
WIP
0xgregthedev 20192bc
Feat/ast 1952 v1 handler testing (#41)
androolloyd 6444d59
feat/AST 1952 v1 handler testing (#43)
androolloyd 97e6932
feat/V1 hook updates (#44)
androolloyd b70045a
working caveat testing and reentrancy guard
0xgregthedev 8b5a3ab
Merge branch 'main' of github.com:AstariaXYZ/starport into feat/cavea…
0xgregthedev 114cce4
remove ownable and change loan.issuer to lender
0xgregthedev 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
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,67 @@ | ||
import {Ownable} from "solady/src/auth/Ownable.sol"; | ||
|
||
abstract contract PausableNonReentrant is Ownable { | ||
uint256 private constant _UNLOCKED = 0x1; | ||
uint256 private constant _LOCKED = 0x2; | ||
uint256 private constant _PAUSED = 0x3; | ||
|
||
uint256 private _state = _UNLOCKED; | ||
|
||
event Paused(); | ||
event Unpaused(); | ||
|
||
error IsPaused(); | ||
error IsLocked(); | ||
error NotPaused(); | ||
|
||
modifier pausableNonReentrant() { | ||
assembly { | ||
//If locked or paused, handle revert cases | ||
if gt(sload(_state.slot), _UNLOCKED) { | ||
if gt(sload(_state.slot), _LOCKED) { | ||
//Revert IsPaused | ||
mstore(0, 0x1309a563) | ||
revert(0x1c, 0x04) | ||
} | ||
//Revert IsLocked | ||
mstore(0, 0xcaa30f55) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _LOCKED) | ||
} | ||
_; | ||
assembly { | ||
sstore(_state.slot, _UNLOCKED) | ||
} | ||
} | ||
|
||
function pause() external onlyOwner { | ||
assembly { | ||
//If locked, prevent owner from overriding state | ||
if eq(sload(_state.slot), _LOCKED) { | ||
//Revert IsLocked | ||
mstore(0, 0xcaa30f55) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _PAUSED) | ||
} | ||
emit Paused(); | ||
} | ||
|
||
function unpause() external onlyOwner { | ||
assembly { | ||
//If not paused, prevent owner from overriding state | ||
if lt(sload(_state.slot), _PAUSED) { | ||
//Revert NotPaused | ||
mstore(0, 0x6cd60201) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _UNLOCKED) | ||
} | ||
emit Unpaused(); | ||
} | ||
|
||
function paused() external view returns (bool) { | ||
return _state == _PAUSED; | ||
} | ||
} |
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.
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.
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.
in my change i did the seaport style nonce increment, but unsure if we care, also we need an event to both so that we can index them/invalidte things
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.
Seaport style sounds good to me. Yeah probably should add the salt event to validateSalt as well
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.
ok can just adopt my methods then they have events and the seaport style nonce update, will add events to the invalidate caveat salt