Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Scarb Workspaces and Modularize Codebase #1038

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For example, this is how to write an ERC20-compliant contract:
```cairo
#[starknet::contract]
mod MyToken {
use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use starknet::ContractAddress;

component!(path: ERC20Component, storage: erc20, event: ERC20Event);
Expand Down
60 changes: 58 additions & 2 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,61 @@
version = 1

[[package]]
name = "openzeppelin"
version = "0.14.0"
name = "openzeppelin_access"
version = "0.1.0"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_account"
version = "0.1.0"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_governance"
version = "0.1.0"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.1.0"

[[package]]
name = "openzeppelin_presets"
version = "0.1.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
]

[[package]]
name = "openzeppelin_security"
version = "0.1.0"

[[package]]
name = "openzeppelin_token"
version = "0.1.0"
dependencies = [
"openzeppelin_account",
"openzeppelin_governance",
"openzeppelin_introspection",
]

[[package]]
name = "openzeppelin_upgrades"
version = "0.1.0"

[[package]]
name = "openzeppelin_utils"
version = "0.1.0"
26 changes: 22 additions & 4 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[package]
[workspace]
members = [
"packages/access",
"packages/account",
"packages/governance",
"packages/introspection",
"packages/presets",
"packages/security",
"packages/token",
"packages/upgrades",
"packages/utils",
]
name = "openzeppelin"
version = "0.14.0"
edition = "2023_11"
Expand All @@ -10,9 +21,16 @@ documentation = "https://docs.openzeppelin.com/contracts-cairo"
readme = "README.md"
repository = "https://github.com/OpenZeppelin/cairo-contracts"
license-file = "LICENSE"
keywords = ["openzeppelin", "starknet", "cairo", "contracts", "security", "standards"]
keywords = [
"openzeppelin",
"starknet",
"cairo",
"contracts",
"security",
"standards",
]

[dependencies]
[workspace.dependencies]
starknet = "2.6.4"

[lib]
Expand All @@ -22,5 +40,5 @@ allowed-libfuncs-list.name = "experimental"
sierra = true
casm = false

[tool.fmt]
[workspace.tool.fmt]
sort-module-level-items = true
22 changes: 11 additions & 11 deletions docs/modules/ROOT/pages/access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ xref:/api/access.adoc#OwnableComponent-initializer[`initializer`] like this:
----
#[starknet::contract]
mod MyContract {
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin_access::ownable::OwnableComponent;
use starknet::ContractAddress;

component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
Expand Down Expand Up @@ -174,9 +174,9 @@ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");

#[starknet::contract]
mod MyContract {
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use openzeppelin_access::accesscontrol::AccessControlComponent;
use openzeppelin_introspection::src5::SRC5Component;
use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use starknet::ContractAddress;
use super::MINTER_ROLE;

Expand Down Expand Up @@ -265,9 +265,9 @@ const BURNER_ROLE: felt252 = selector!("BURNER_ROLE");

#[starknet::contract]
mod MyContract {
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use openzeppelin_access::accesscontrol::AccessControlComponent;
use openzeppelin_introspection::src5::SRC5Component;
use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use starknet::ContractAddress;
use super::{MINTER_ROLE, BURNER_ROLE};

Expand Down Expand Up @@ -387,10 +387,10 @@ const BURNER_ROLE: felt252 = selector!("BURNER_ROLE");

#[starknet::contract]
mod MyContract {
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::access::accesscontrol::DEFAULT_ADMIN_ROLE;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use openzeppelin_access::accesscontrol::AccessControlComponent;
use openzeppelin_access::accesscontrol::DEFAULT_ADMIN_ROLE;
use openzeppelin_introspection::src5::SRC5Component;
use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use starknet::ContractAddress;
use super::{MINTER_ROLE, BURNER_ROLE};

Expand Down
24 changes: 12 additions & 12 deletions docs/modules/ROOT/pages/accounts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ Constructing an account contract requires integrating both {account-component} a
----
#[starknet::contract(account)]
mod MyAccount {
use openzeppelin::account::AccountComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin_account::AccountComponent;
use openzeppelin_introspection::src5::SRC5Component;

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
Expand Down Expand Up @@ -202,10 +202,10 @@ Here’s an example of a basic contract:
----
#[starknet::contract(account)]
mod MyEthAccount {
use openzeppelin::account::EthAccountComponent;
use openzeppelin::account::interface::EthPublicKey;
use openzeppelin::account::utils::secp256k1::Secp256k1PointSerde;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin_account::EthAccountComponent;
use openzeppelin_account::interface::EthPublicKey;
use openzeppelin_account::utils::secp256k1::Secp256k1PointSerde;
use openzeppelin_introspection::src5::SRC5Component;
use starknet::ClassHash;

component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent);
Expand Down Expand Up @@ -304,8 +304,8 @@ First, let's take the example account we created before and deploy it:
```[,cairo]
#[starknet::contract(account)]
mod MyAccount {
use openzeppelin::account::AccountComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin_account::AccountComponent;
use openzeppelin_introspection::src5::SRC5Component;

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
Expand Down Expand Up @@ -387,10 +387,10 @@ First, let's take the example account we created before and deploy it:
```[,cairo]
#[starknet::contract(account)]
mod MyEthAccount {
use openzeppelin::account::EthAccountComponent;
use openzeppelin::account::interface::EthPublicKey;
use openzeppelin::account::utils::secp256k1::Secp256k1PointSerde;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin_account::EthAccountComponent;
use openzeppelin_account::interface::EthPublicKey;
use openzeppelin_account::utils::secp256k1::Secp256k1PointSerde;
use openzeppelin_introspection::src5::SRC5Component;

component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
Expand Down
6 changes: 3 additions & 3 deletions docs/modules/ROOT/pages/api/access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ assigned each to multiple accounts.
=== `++OwnableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.14.0/src/access/ownable/ownable.cairo[{github-icon},role=heading-link]

```cairo
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin_access::ownable::OwnableComponent;
```

`Ownable` provides a basic access control mechanism where an account
Expand Down Expand Up @@ -276,7 +276,7 @@ Emitted when the ownership is transferred.
:RoleAdminChanged: xref:#IAccessControl-RoleAdminChanged[RoleAdminChanged]

```cairo
use openzeppelin::access::accesscontrol::interface::IAccessControl;
use openzeppelin_access::accesscontrol::interface::IAccessControl;
```

External interface of AccessControl.
Expand Down Expand Up @@ -407,7 +407,7 @@ Emitted when `account` is revoked `role`.
:revoke_role: xref:#AccessControlComponent-revoke_role[revoke_role]

```cairo
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin_access::accesscontrol::AccessControlComponent;
```

Component that allows contracts to implement role-based access control mechanisms.
Expand Down
10 changes: 5 additions & 5 deletions docs/modules/ROOT/pages/api/account.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include::../utils/_common.adoc[]
=== `++ISRC6++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.14.0/src/account/interface.cairo[{github-icon},role=heading-link]

```cairo
use openzeppelin::account::interface::ISRC6;
use openzeppelin_account::interface::ISRC6;
```

Interface of the SRC6 Standard Account as defined in the {snip6}.
Expand Down Expand Up @@ -72,7 +72,7 @@ Returns the short string `'VALID'` if valid, otherwise it reverts.
:starknet-curve: https://docs.starknet.io/documentation/architecture_and_concepts/Cryptography/stark-curve/[Starknet curve]

```cairo
use openzeppelin::account::AccountComponent;
use openzeppelin_account::AccountComponent;
```
Account component implementing xref:ISRC6[`ISRC6`] for signatures over the {starknet-curve}.

Expand Down Expand Up @@ -322,7 +322,7 @@ Emitted when a `public_key` is removed.
:secp256k1-curve: https://en.bitcoin.it/wiki/Secp256k1[Secp256k1 curve]

```cairo
use openzeppelin::account::eth_account::EthAccountComponent;
use openzeppelin_account::eth_account::EthAccountComponent;
```
Account component implementing xref:ISRC6[`ISRC6`] for signatures over the {secp256k1-curve}.

Expand Down Expand Up @@ -573,7 +573,7 @@ Emitted when a `public_key` is removed.
=== `++AccountUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.14.0/src/presets/account.cairo[{github-icon},role=heading-link]

```cairo
use openzeppelin::presets::AccountUpgradeable;
use openzeppelin_presets::AccountUpgradeable;
```

Upgradeable account contract leveraging xref:#AccountComponent[AccountComponent].
Expand Down Expand Up @@ -634,7 +634,7 @@ Requirements:
=== `++EthAccountUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.14.0/src/presets/eth_account.cairo[{github-icon},role=heading-link]

```cairo
use openzeppelin::presets::EthAccountUpgradeable;
use openzeppelin_presets::EthAccountUpgradeable;
```

Upgradeable account contract leveraging xref:#EthAccountComponent[EthAccountComponent].
Expand Down
14 changes: 7 additions & 7 deletions docs/modules/ROOT/pages/api/erc1155.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TIP: For an overview of ERC1155, read our xref:erc1155.adoc[ERC1155 guide].

[.hljs-theme-dark]
```cairo
use openzeppelin::token::erc1155::interface::IERC1155;
use openzeppelin_token::erc1155::interface::IERC1155;
```
Interface of the IERC1155 standard as defined in {eip1155}.

Expand Down Expand Up @@ -130,7 +130,7 @@ Emitted when the token URI is updated to `value` for the `id` token.

[.hljs-theme-dark]
```cairo
use openzeppelin::token::erc1155::interface::IERC1155MetadataURI;
use openzeppelin_token::erc1155::interface::IERC1155MetadataURI;
```
Interface for the optional metadata function in {eip1155-metadata}[EIP1155].

Expand Down Expand Up @@ -160,7 +160,7 @@ Returns the Uniform Resource Identifier (URI) for the `token_id` token.

[.hljs-theme-dark]
```cairo
use openzeppelin::token::erc1155::ERC1155Component;
use openzeppelin_token::erc1155::ERC1155Component;
```

ERC1155 component implementing <<IERC1155,IERC1155>> and <<IERC1155MetadataURI,IERC1155MetadataURI>>.
Expand Down Expand Up @@ -246,7 +246,7 @@ Hooks are functions which implementations can extend the functionality of the co
using ERC1155Component is expected to provide an implementation of the ERC1155HooksTrait. For basic token contracts, an
empty implementation with no logic must be provided.

TIP: You can use `openzeppelin::token::erc1155::ERC1155HooksEmptyImpl` which is already available as part of the library
TIP: You can use `openzeppelin_token::erc1155::ERC1155HooksEmptyImpl` which is already available as part of the library
for this purpose.

[.contract-item]
Expand Down Expand Up @@ -547,7 +547,7 @@ See <<IERC1155-URI,IERC1155::URI>>.

[.hljs-theme-dark]
```cairo
use openzeppelin::token::erc1155::interface::IERC1155Receiver;
use openzeppelin_token::erc1155::interface::IERC1155Receiver;
```

Interface for contracts that support receiving token transfers from `ERC1155` contracts.
Expand Down Expand Up @@ -587,7 +587,7 @@ via <<IERC1155-safe_batch_transfer_from,IERC1155::safe_batch_transfer_from>> by

[.hljs-theme-dark]
```cairo
use openzeppelin::token::erc1155::ERC1155ReceiverComponent;
use openzeppelin_token::erc1155::ERC1155ReceiverComponent;
```

ERC1155Receiver component implementing <<IERC1155Receiver,IERC1155Receiver>>.
Expand Down Expand Up @@ -663,7 +663,7 @@ Registers the `IERC1155Receiver` interface ID as supported through introspection
=== `++ERC1155Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.14.0/src/presets/erc1155.cairo[{github-icon},role=heading-link]

```cairo
use openzeppelin::presets::ERC1155;
use openzeppelin_presets::ERC1155;
```

Upgradeable ERC1155 contract leveraging xref:#ERC1155Component[ERC1155Component].
Expand Down
Loading
Loading