Skip to content

Commit

Permalink
Merge branch 'remove-dual-dispatchers' of github.com:OpenZeppelin/cai…
Browse files Browse the repository at this point in the history
…ro-contracts into feat/remove-account-dual-dispatchers
  • Loading branch information
ericnordelo committed Oct 2, 2024
2 parents 046acdd + 3ad8c7f commit bb2f5aa
Show file tree
Hide file tree
Showing 122 changed files with 1,115 additions and 408 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/typos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
uses: actions/checkout@v4

- name: Check for typos
uses: crate-ci/typos@8e6a4285bcbde632c5d79900a7779746e8b7ea3f
uses: crate-ci/typos@f12cee1d8f3c79282a98ecb41d235aef17dfa8fd
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Bump scarb to v2.8.3 (#1166)

## 0.17.0 (2024-09-23)

### Added

- `into_base_16_string_no_padding` function to the test helpers (#1137)
Expand All @@ -24,6 +30,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `execute_calls` function from account utils (#1150)
- calls param type changed from `Array<Call>` to `Span<Call>`

### Deprecated

- DualCase dispatchers

## 0.16.0 (2024-08-30)

### Added
Expand Down
24 changes: 7 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ Edit `scarb.toml` and add:

```toml
[dependencies]
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" }
openzeppelin = "0.17.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:
The previous example would import the entire library. We can also add each package as a separate dependency to improve the building time by not including modules that won't be used:

```toml
[dependencies]
openzeppelin_token = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" }
openzeppelin_token = "0.17.0"
```

Build the project to download it:
Expand All @@ -72,8 +72,7 @@ For example, this is how to write an ERC20-compliant contract:
```cairo
#[starknet::contract]
mod MyToken {
// If only the token package was added as a dependency, use `openzeppelin_token::` instead
use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use starknet::ContractAddress;
component!(path: ERC20Component, storage: erc20, event: ERC20Event);
Expand Down Expand Up @@ -113,22 +112,13 @@ mod MyToken {

### Unsupported

[`DualCase` dispatchers](https://docs.openzeppelin.com/contracts-cairo/0.16.0/interfaces#dualcase_dispatchers) rely on Sierra's ability to catch a revert to resume execution. Currently, Starknet live chains (testnets and mainnet) don't implement that behavior. Starknet's testing framework does support it.
[`DualCase` dispatchers](https://docs.openzeppelin.com/contracts-cairo/0.17.0/interfaces#dualcase_dispatchers) rely on Sierra's ability to catch a revert to resume execution. Currently, Starknet live chains (testnets and mainnet) don't implement that behavior. Starknet's testing framework does support it.

## Learn

<!-- ### Documentation
### Documentation

Check out the [full documentation site](https://docs.openzeppelin.com/contracts-cairo)! Featuring:
- [Accounts](https://docs.openzeppelin.com/contracts-cairo/0.6.1/accounts)
- [ERC20](https://docs.openzeppelin.com/contracts-cairo/0.6.1/erc20)
- [ERC721](https://docs.openzeppelin.com/contracts-cairo/0.6.1/erc721)
- [ERC1155](https://docs.openzeppelin.com/contracts-cairo/0.6.1/erc1155)
- [Contract extensibility pattern](https://docs.openzeppelin.com/contracts-cairo/0.6.1/extensibility)
- [Proxies and upgrades](https://docs.openzeppelin.com/contracts-cairo/0.6.1/proxies)
- [Security](https://docs.openzeppelin.com/contracts-cairo/0.6.1/security)
- [Utilities](https://docs.openzeppelin.com/contracts-cairo/0.6.1/utilities) -->
Check out the [full documentation site](https://docs.openzeppelin.com/contracts-cairo)!

### Cairo

Expand Down
28 changes: 14 additions & 14 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version = 1

[[package]]
name = "openzeppelin"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
Expand All @@ -23,7 +23,7 @@ dependencies = [

[[package]]
name = "openzeppelin_access"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_test_common",
Expand All @@ -34,7 +34,7 @@ dependencies = [

[[package]]
name = "openzeppelin_account"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_test_common",
Expand All @@ -45,7 +45,7 @@ dependencies = [

[[package]]
name = "openzeppelin_finance"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_test_common",
Expand All @@ -56,7 +56,7 @@ dependencies = [

[[package]]
name = "openzeppelin_governance"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_introspection",
Expand All @@ -66,21 +66,21 @@ dependencies = [

[[package]]
name = "openzeppelin_introspection"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "openzeppelin_merkle_tree"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "openzeppelin_presets"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
Expand All @@ -95,15 +95,15 @@ dependencies = [

[[package]]
name = "openzeppelin_security"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_testing",
"snforge_std",
]

[[package]]
name = "openzeppelin_test_common"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
Expand All @@ -117,14 +117,14 @@ dependencies = [

[[package]]
name = "openzeppelin_testing"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "openzeppelin_token"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_account",
"openzeppelin_governance",
Expand All @@ -136,7 +136,7 @@ dependencies = [

[[package]]
name = "openzeppelin_upgrades"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_test_common",
"openzeppelin_testing",
Expand All @@ -145,7 +145,7 @@ dependencies = [

[[package]]
name = "openzeppelin_utils"
version = "0.16.0"
version = "0.17.0"
dependencies = [
"openzeppelin_testing",
"snforge_std",
Expand Down
4 changes: 2 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ version.workspace = true
keywords.workspace = true

[workspace.package]
version = "0.16.0"
version = "0.17.0"
edition = "2024_07"
cairo-version = "2.8.2"
scarb-version = "2.8.2"
scarb-version = "2.8.3"
authors = ["OpenZeppelin Community <[email protected]>"]
description = "OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup"
documentation = "https://docs.openzeppelin.com/contracts-cairo"
Expand Down
4 changes: 2 additions & 2 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: contracts-cairo
title: Contracts for Cairo
version: 0.16.0
version: 0.17.0
nav:
- modules/ROOT/nav.adoc
asciidoc:
attributes:
page-sidebar-collapse-default: 'Access,Accounts,Governance,Introspection,Security,ERC20,ERC721,ERC1155,Upgrades,Universal Deployer Contract'
page-sidebar-collapse-default: 'Access,Accounts,Finance,Governance,Introspection,Security,ERC20,ERC721,ERC1155,Upgrades,Universal Deployer Contract'
3 changes: 3 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
** xref:accounts.adoc[Accounts]
*** xref:/api/account.adoc[API Reference]

** xref:finance.adoc[Finance]
*** xref:/api/finance.adoc[API Reference]
** xref:governance.adoc[Governance]
*** xref:/api/governance.adoc[API Reference]

Expand Down
24 changes: 12 additions & 12 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 @@ -376,7 +376,7 @@ This mechanism can be used to create complex permissioning structures resembling
provides an easy way to manage simpler applications. `AccessControl` includes a special role with the role identifier
of `0`, called `DEFAULT_ADMIN_ROLE`, which acts as the *default admin role for all roles*.
An account with this role will be able to manage any other role, unless
xref:api/access.adoc#AccessControlComponent-_set_role_admin[`_set_role_admin`] is used to select a new admin role.
xref:api/access.adoc#AccessControlComponent-set_role_admin[`set_role_admin`] is used to select a new admin role.

Let's take a look at the ERC20 token example, this time taking advantage of the default admin role:

Expand All @@ -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
20 changes: 10 additions & 10 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,9 +202,9 @@ Here’s an example of a basic contract:
----
#[starknet::contract(account)]
mod MyEthAccount {
use openzeppelin::account::EthAccountComponent;
use openzeppelin::account::interface::EthPublicKey;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin_account::EthAccountComponent;
use openzeppelin_account::interface::EthPublicKey;
use openzeppelin_introspection::src5::SRC5Component;
use starknet::ClassHash;
component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent);
Expand Down Expand Up @@ -303,8 +303,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 @@ -386,9 +386,9 @@ 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::introspection::src5::SRC5Component;
use openzeppelin_account::EthAccountComponent;
use openzeppelin_account::interface::EthPublicKey;
use openzeppelin_introspection::src5::SRC5Component;

component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
Expand Down
12 changes: 6 additions & 6 deletions docs/modules/ROOT/pages/api/access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ assigned each to multiple accounts.

[.contract]
[[OwnableComponent]]
=== `++OwnableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/access/src/ownable/ownable.cairo[{github-icon},role=heading-link]
=== `++OwnableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/access/src/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 @@ -255,7 +255,7 @@ Emitted when the ownership is transferred.

[.contract]
[[IAccessControl]]
=== `++IAccessControl++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/access/src/accesscontrol/interface.cairo[{github-icon},role=heading-link]
=== `++IAccessControl++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/access/src/accesscontrol/interface.cairo[{github-icon},role=heading-link]

:grant_role: xref:#IAccessControl-grant_role[grant_role]
:revoke_role: xref:#IAccessControl-revoke_role[revoke_role]
Expand All @@ -264,7 +264,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 @@ -388,14 +388,14 @@ Emitted when `account` is revoked `role`.

[.contract]
[[AccessControlComponent]]
=== `++AccessControlComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/access/src/accesscontrol/accesscontrol.cairo[{github-icon},role=heading-link]
=== `++AccessControlComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/access/src/accesscontrol/accesscontrol.cairo[{github-icon},role=heading-link]

:assert_only_role: xref:#AccessControlComponent-assert_only_role
:grant_role: xref:#AccessControlComponent-grant_role[grant_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
Loading

0 comments on commit bb2f5aa

Please sign in to comment.