Open MaayanShore opened 1 week ago
Where did you see this syntex?
I didnt find it in the cairo-contracts repository.
I think that the correct syntex to import the Ownable component is:
use openzeppelin::access::ownable::OwnableComponent;
mod erc20 { use starknet::ContractAddress; use openzeppelin::token::erc20::ERC20;
#[storage]
struct Storage {}
#[constructor]
fn constructor(
ref self: ContractState,
initial_supply: u256,
recipient: ContractAddress
) {
let name = 'MyToken';
let symbol = 'MTK';
let mut unsafe_state = ERC20::unsafe_new_contract_state();
ERC20::InternalImpl::initializer(ref unsafe_state, name, symbol);
ERC20::InternalImpl::_mint(ref unsafe_state, recipient, initial_supply);
}
#[generate_trait]
impl Ierc20Impl of Ierc20 {
fn balance_of(self: @ContractState, account: ContractAddress) -> u256 {
let unsafe_state = ERC20::unsafe_new_contract_state();
ERC20::ERC20Impl::balance_of(@unsafe_state, account)
}
fn transfer(ref self: ContractState, recipient: ContractAddress, amount: u256) -> bool {
let mut unsafe_state = ERC20::unsafe_new_contract_state();
ERC20::ERC20Impl::transfer(ref unsafe_state, recipient, amount)
}
}
}
Trying to import the Ownable library from Openzepplin like this: use openzeppelin::access::ownable::library {Ownable}; but I got a error in the import