pub fn is_reentrant() -> bool 
Expand description

Returns true if the reentrancy pattern is detected, and false otherwise.

Additional Information

Detects reentrancy by iteratively checking previous calls in the current call stack for a
contract ID equal to the current contract ID. If a match is found, it returns true, else false.

Returns

  • [bool] - true if reentrancy pattern has occured.

Examples

use sway_libs::reentrancy::is_reentrant;

fn foo() {
    assert(is_reentrant() == false);
    // Do critical stuff here
}