Hello OpenZeppelin Community,
I'm currently working on a Cairo smart contract and have run into an issue with implementing the ReentrancyGuard
component from the OpenZeppelin library for Cairo. I'm using OpenZeppelin Contracts for Cairo version 0.8.0-beta.0.
Problem Description:
When trying to declare the ReentrancyGuard
component in my contract using the component!
macro, I encounter the following error during compilation with scarb build
:
error: Plugin diagnostic: Invalid component macro, expected `component!(name: "<component_name>", storage: "<storage_name>", event: "<event_name>");`
--> [file path]:[line number]
component!(name: ReentrancyGuard, storage: ReentrancyGuard);
The ReentrancyGuard
component is imported and defined as follows:
#[starknet::component]
mod ReentrancyGuard {
// ... (definition)
}
I've tried using the component!
macro in various ways, including:
component!(name: ReentrancyGuard, storage: ReentrancyGuard);
component!(name: ReentrancyGuard, storage: Storage);
None of these variations resolve the issue. The error message suggests that an event
parameter is also expected in the macro, which seems unusual for a ReentrancyGuard
component.
Here is how I am using the component and declaring it in the contract:
use openzeppelin::security::reentrancyguard::ReentrancyGuard;
// Declare the ReentrancyGuard component
component!(path: ReentrancyGuard, storage: Storage);
...
Questions:
- How should the
component!
macro be correctly used for declaring theReentrancyGuard
component in this context? - Why does the error message indicate the need for an
event
parameter in thecomponent!
macro? - I've noticed there's no specific documentation for the
ReentrancyGuard
in the current version (0.8.0-beta.0) of OpenZeppelin Contracts for Cairo. Is there any available documentation or example that could guide me in the correct implementation of this component?
Any assistance or guidance on this matter would be greatly appreciated. Here is a link to the contract with the issue:
https://github.com/henryf10h/reflect_cairo/blob/main/src/contracts/ERC20wrapper_V0.cairo
Thank you in advance for your help!