Skip to content

Commit

Permalink
reset flag after execution
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Dec 24, 2024
1 parent 5560c58 commit 7efe449
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,20 @@ contract Gateway is IGateway, IInitializable, IUpgradable {

modifier nonreentrant() {
assembly {
// Check if flag is set and if true revert because it means the function is currently executing.
if tload(0) { revert(0, 0) }

// Set the flag to mark the the function is currently executing.
tstore(0, 1)
}

// Execute the function here
_;

assembly {
// Reset the flag as the function has completed executing.
tstore(0, 0)
}
}

constructor(
Expand Down

0 comments on commit 7efe449

Please sign in to comment.