diff --git a/CHANGELOG.md b/CHANGELOG.md index a1ff29a21..761e3baa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - TimelockController component (#996) - HashCall implementation (#996) +- Separated package for each submodule (#1065) + - `openzeppelin_access` + - `openzeppelin_account` + - `openzeppelin_governance` + - `openzeppelin_introspection` + - `openzeppelin_presets` + - `openzeppelin_security` + - `openzeppelin_token` + - `openzeppelin_upgrades` + - `openzeppelin_utils` ### Changed diff --git a/README.md b/README.md index 390523ae6..82615cb0e 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,13 @@ Edit `scarb.toml` and add: openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.15.0-rc.0" } ``` +The previous example would import the entire library. we can also add each package as a separated dependency to improve the time for building by not including modules that won't be used: + +```toml +[dependencies] +openzeppelin_token = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.15.0-rc.0" } +``` + Build the project to download it: ```bash @@ -65,7 +72,8 @@ For example, this is how to write an ERC20-compliant contract: ```cairo #[starknet::contract] mod MyToken { - use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + // If only the token package was added as a dependency, use `openzeppelin_token::` instead + use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event);