-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update MiddlewareProtect to use tstore
- Loading branch information
Showing
5 changed files
with
56 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
library ReentrancyState { | ||
// bytes32(uint256(keccak256("ReentrancyState")) - 1) | ||
bytes32 constant REENTRANCY_STATE_SLOT = 0xbedc9a60a226d4ae7b727cbc828f66c94c4eead57777428ceab2f04b0efca3a5; | ||
|
||
function unlock() internal { | ||
assembly { | ||
tstore(REENTRANCY_STATE_SLOT, 0) | ||
} | ||
} | ||
|
||
function lockSwap() internal { | ||
assembly { | ||
tstore(REENTRANCY_STATE_SLOT, 1) | ||
} | ||
} | ||
|
||
function lockSwapRemove() internal { | ||
assembly { | ||
tstore(REENTRANCY_STATE_SLOT, 2) | ||
} | ||
} | ||
|
||
function read() internal view returns (uint256 state) { | ||
assembly { | ||
state := tload(REENTRANCY_STATE_SLOT) | ||
} | ||
} | ||
|
||
function swapLocked() internal view returns (bool) { | ||
return read() == 1 || read() == 2; | ||
} | ||
|
||
function removeLocked() internal view returns (bool) { | ||
return read() == 2; | ||
} | ||
} |
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
Submodule forge-gas-snapshot
updated
19 files
+0 −1 | .forge-snapshots/add.snap | |
+0 −1 | .forge-snapshots/addClosure.snap | |
+1 −1 | .forge-snapshots/checkManyAdd.snap | |
+1 −1 | .forge-snapshots/checkSize.snap | |
+1 −1 | .forge-snapshots/internalClosure.snap | |
+1 −1 | .forge-snapshots/manyAdd.snap | |
+1 −1 | .forge-snapshots/manySstore.snap | |
+1 −0 | .forge-snapshots/singleSstore.snap | |
+1 −0 | .forge-snapshots/singleSstoreClosure.snap | |
+1 −0 | .forge-snapshots/singleSstoreLastCall.snap | |
+1 −1 | .forge-snapshots/sizeTarget.snap | |
+1 −1 | .forge-snapshots/sstoreClosure.snap | |
+1 −1 | .github/workflows/test.yml | |
+21 −0 | LICENSE | |
+1 −1 | lib/forge-std | |
+11 −2 | src/GasSnapshot.sol | |
+4 −0 | src/test/SimpleOperations.sol | |
+5 −2 | src/utils/UintString.sol | |
+31 −23 | test/GasSnapshot.t.sol |
Submodule forge-std
updated
41 files
Submodule openzeppelin-contracts
updated
619 files