Skip to content

Commit

Permalink
Bump scarb to v2.9.1 (OpenZeppelin#1239)
Browse files Browse the repository at this point in the history
* update fmt

* add missing dev dep

* update scarb version in doc

* add changelog entry

* update changelog entry

* Apply suggestions from code review

Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>

* add snforge entry to changelog

* test coverage when not updating snforge

* remove snforge entry from changelog

* comment out cairo-coverage and codecov in ci

* re-bump snforge

* tmp remove coverage from command

---------

Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
  • Loading branch information
andrew-fleming and ericnordelo authored Dec 4, 2024
1 parent 0676415 commit 83a33fc
Show file tree
Hide file tree
Showing 162 changed files with 1,625 additions and 1,566 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ jobs:
with:
starknet-foundry-version: ${{ env.FOUNDRY_VERSION }}

- name: Install cairo-coverage
run: curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh
# Issue with cairo-coverage. Re-add to CI once issues are fixed.
#
# - name: Install cairo-coverage
# run: curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh

- name: Markdown lint
uses: DavidAnson/markdownlint-cli2-action@eb5ca3ab411449c66620fe7f1b3c9e10547144b0 # v16
Expand All @@ -47,11 +49,16 @@ jobs:
- name: Cairo lint
run: scarb fmt --check --workspace

- name: Run tests and generate coverage report
run: snforge test --workspace --coverage
- name: Run tests
run: snforge test --workspace

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
# Issue with cairo-coverage. Re-add to CI once issues are fixed.
#
# - name: Run tests and generate coverage report
# run: snforge test --workspace --coverage
#
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# file: ./coverage.lcov
# token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed (Breaking)

- Bump snforge_std to v0.34.0 (#1239)
- Bump scarb to v2.9.1 (#1239)
- The initializer in `OwnableComponent` now checks that `owner` is not the zero address (#1221)
- Add `verifying_contract` member to the `Delegation` struct used in Votes `delegate_by_sig` (#1214)
use crate::votes::VotesComponent::VotingUnitsTrait;
Expand Down
9 changes: 5 additions & 4 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies = [
"openzeppelin_test_common",
"openzeppelin_testing",
"openzeppelin_token",
"openzeppelin_utils",
"snforge_std",
]

Expand Down Expand Up @@ -165,15 +166,15 @@ dependencies = [

[[package]]
name = "snforge_scarb_plugin"
version = "0.33.0"
version = "0.34.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:b4dd6088372decd367652827091e0589bbf6bc550dfc3957baa3e9c61d6eb449"
checksum = "sha256:56f2b06ff2f0d8bbdfb7fb6c211fba7e4da6e5334ea70ba849af329a739faf11"

[[package]]
name = "snforge_std"
version = "0.33.0"
version = "0.34.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:f7dc3349f8a6ef4915c93df447a00bd5a53a31129fd0990a00afa0ad31d91b06"
checksum = "sha256:bd20964bde07e6fd0f7adb50d41216f05d66abd422ed82241030369333385876"
dependencies = [
"snforge_scarb_plugin",
]
11 changes: 6 additions & 5 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ name = "openzeppelin"
readme = "README.md"
version.workspace = true
keywords.workspace = true
edition.workspace = true

[workspace.package]
version = "0.20.0-rc.0"
edition = "2024_07"
cairo-version = "2.8.5"
scarb-version = "2.8.5"
cairo-version = "2.9.1"
scarb-version = "2.9.1"
authors = ["OpenZeppelin Community <maintainers@openzeppelin.org>"]
description = "OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup"
documentation = "https://docs.openzeppelin.com/contracts-cairo"
Expand All @@ -40,9 +41,9 @@ keywords = [
]

[workspace.dependencies]
assert_macros = "2.8.5"
starknet = "2.8.5"
snforge_std = "0.33.0"
assert_macros = "2.9.1"
starknet = "2.9.1"
snforge_std = "0.34.0"

[dependencies]
starknet.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ before proceeding, and run the following command to check that the installation
----
$ scarb --version
scarb 2.8.5 (3967bd4a6 2024-11-18)
cairo: 2.8.5 (https://crates.io/crates/cairo-lang-compiler/2.8.5)
scarb 2.9.1 (aba4f604a 2024-11-29)
cairo: 2.9.1 (https://crates.io/crates/cairo-lang-compiler/2.9.1)
sierra: 1.6.0
----

Expand Down
56 changes: 28 additions & 28 deletions packages/access/src/accesscontrol/accesscontrol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#[starknet::component]
pub mod AccessControlComponent {
use crate::accesscontrol::interface;
use openzeppelin_introspection::src5::SRC5Component;
use openzeppelin_introspection::src5::SRC5Component::InternalImpl as SRC5InternalImpl;
use openzeppelin_introspection::src5::SRC5Component::SRC5Impl;
use openzeppelin_introspection::src5::SRC5Component;
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
Expand All @@ -48,7 +48,7 @@ pub mod AccessControlComponent {
pub struct RoleGranted {
pub role: felt252,
pub account: ContractAddress,
pub sender: ContractAddress
pub sender: ContractAddress,
}

/// Emitted when `role` is revoked for `account`.
Expand All @@ -60,7 +60,7 @@ pub mod AccessControlComponent {
pub struct RoleRevoked {
pub role: felt252,
pub account: ContractAddress,
pub sender: ContractAddress
pub sender: ContractAddress,
}

/// Emitted when `new_admin_role` is set as `role`'s admin role, replacing `previous_admin_role`
Expand All @@ -71,7 +71,7 @@ pub mod AccessControlComponent {
pub struct RoleAdminChanged {
pub role: felt252,
pub previous_admin_role: felt252,
pub new_admin_role: felt252
pub new_admin_role: felt252,
}

pub mod Errors {
Expand All @@ -84,11 +84,11 @@ pub mod AccessControlComponent {
TContractState,
+HasComponent<TContractState>,
+SRC5Component::HasComponent<TContractState>,
+Drop<TContractState>
+Drop<TContractState>,
> of interface::IAccessControl<ComponentState<TContractState>> {
/// Returns whether `account` has been granted `role`.
fn has_role(
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> bool {
self.AccessControl_role_member.read((role, account))
}
Expand All @@ -106,7 +106,7 @@ pub mod AccessControlComponent {
///
/// - The caller must have `role`'s admin role.
fn grant_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
let admin = Self::get_role_admin(@self, role);
self.assert_only_role(admin);
Expand All @@ -121,7 +121,7 @@ pub mod AccessControlComponent {
///
/// - The caller must have `role`'s admin role.
fn revoke_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
let admin = Self::get_role_admin(@self, role);
self.assert_only_role(admin);
Expand All @@ -141,7 +141,7 @@ pub mod AccessControlComponent {
///
/// - The caller must be `account`.
fn renounce_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
let caller = get_caller_address();
assert(caller == account, Errors::INVALID_CALLER);
Expand All @@ -155,10 +155,10 @@ pub mod AccessControlComponent {
TContractState,
+HasComponent<TContractState>,
+SRC5Component::HasComponent<TContractState>,
+Drop<TContractState>
+Drop<TContractState>,
> of interface::IAccessControlCamel<ComponentState<TContractState>> {
fn hasRole(
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> bool {
AccessControl::has_role(self, role, account)
}
Expand All @@ -168,19 +168,19 @@ pub mod AccessControlComponent {
}

fn grantRole(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControl::grant_role(ref self, role, account);
}

fn revokeRole(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControl::revoke_role(ref self, role, account);
}

fn renounceRole(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControl::renounce_role(ref self, role, account);
}
Expand All @@ -191,7 +191,7 @@ pub mod AccessControlComponent {
TContractState,
+HasComponent<TContractState>,
impl SRC5: SRC5Component::HasComponent<TContractState>,
+Drop<TContractState>
+Drop<TContractState>,
> of InternalTrait<TContractState> {
/// Initializes the contract by registering the IAccessControl interface ID.
fn initializer(ref self: ComponentState<TContractState>) {
Expand All @@ -212,7 +212,7 @@ pub mod AccessControlComponent {
///
/// Emits a `RoleAdminChanged` event.
fn set_role_admin(
ref self: ComponentState<TContractState>, role: felt252, admin_role: felt252
ref self: ComponentState<TContractState>, role: felt252, admin_role: felt252,
) {
let previous_admin_role: felt252 = AccessControl::get_role_admin(@self, role);
self.AccessControl_role_admin.write(role, admin_role);
Expand All @@ -225,7 +225,7 @@ pub mod AccessControlComponent {
///
/// May emit a `RoleGranted` event.
fn _grant_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
if !AccessControl::has_role(@self, role, account) {
let caller: ContractAddress = get_caller_address();
Expand All @@ -240,7 +240,7 @@ pub mod AccessControlComponent {
///
/// May emit a `RoleRevoked` event.
fn _revoke_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
if AccessControl::has_role(@self, role, account) {
let caller: ContractAddress = get_caller_address();
Expand All @@ -255,11 +255,11 @@ pub mod AccessControlComponent {
TContractState,
+HasComponent<TContractState>,
impl SRC5: SRC5Component::HasComponent<TContractState>,
+Drop<TContractState>
+Drop<TContractState>,
> of interface::AccessControlABI<ComponentState<TContractState>> {
// IAccessControl
fn has_role(
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> bool {
AccessControl::has_role(self, role, account)
}
Expand All @@ -269,26 +269,26 @@ pub mod AccessControlComponent {
}

fn grant_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControl::grant_role(ref self, role, account);
}

fn revoke_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControl::revoke_role(ref self, role, account);
}

fn renounce_role(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControl::renounce_role(ref self, role, account);
}

// IAccessControlCamel
fn hasRole(
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress
self: @ComponentState<TContractState>, role: felt252, account: ContractAddress,
) -> bool {
AccessControlCamel::hasRole(self, role, account)
}
Expand All @@ -298,26 +298,26 @@ pub mod AccessControlComponent {
}

fn grantRole(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControlCamel::grantRole(ref self, role, account);
}

fn revokeRole(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControlCamel::revokeRole(ref self, role, account);
}

fn renounceRole(
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress
ref self: ComponentState<TContractState>, role: felt252, account: ContractAddress,
) {
AccessControlCamel::renounceRole(ref self, role, account);
}

// ISRC5
fn supports_interface(
self: @ComponentState<TContractState>, interface_id: felt252
self: @ComponentState<TContractState>, interface_id: felt252,
) -> bool {
let src5 = get_dep_component!(self, SRC5);
src5.supports_interface(interface_id)
Expand Down
Loading

0 comments on commit 83a33fc

Please sign in to comment.