forked from OpenZeppelin/cairo-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
library.cairo
37 lines (30 loc) · 922 Bytes
/
library.cairo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# SPDX-License-Identifier: MIT
# OpenZeppelin Contracts for Cairo v0.2.1 (security/reentrancyguard/library.cairo)
%lang starknet
from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.cairo.common.bool import TRUE, FALSE
@storage_var
func ReentrancyGuard_entered() -> (res: felt):
end
namespace ReentrancyGuard:
func _start{
syscall_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr
}():
let (has_entered) = ReentrancyGuard_entered.read()
with_attr error_message("ReentrancyGuard: reentrant call"):
assert has_entered = FALSE
end
ReentrancyGuard_entered.write(TRUE)
return ()
end
func _end{
syscall_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr
}():
ReentrancyGuard_entered.write(FALSE)
return ()
end
end