Skip to content

Commit

Permalink
πŸ‘·πŸ»β€β™‚οΈ Update lock mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders committed Jul 17, 2023
1 parent 7ac1fc5 commit c1c9990
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ contract Account is IAccount, Auth, OpsReady {
mapping(uint256 id => ConditionalOrder order) internal conditionalOrders;

/// @notice value used for reentrancy protection
/// @dev nonReentrant checks that locked is NOT EQUAL to 2
uint256 internal locked;

/*//////////////////////////////////////////////////////////////
Expand All @@ -116,12 +117,14 @@ contract Account is IAccount, Auth, OpsReady {
}

modifier nonReentrant() {
if (locked == 1) revert Reentrancy();
locked = 1;
/// @dev locked is intially set to 0 due to the proxy nature of SM accounts
/// however after the inital call to nonReentrant(), locked will be set to 1
if (locked == 2) revert Reentrancy();
locked = 2;

_;

locked = 0;
locked = 1;
}

/*//////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c1c9990

Please sign in to comment.