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

Upgrade scarb edition to 2024_07 #1138

Merged
merged 7 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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 Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ version.workspace = true

[workspace.package]
version = "0.16.0"
edition = "2023_11"
edition = "2024_07"
cairo-version = "2.8.0"
scarb-version = "2.8.0"
authors = ["OpenZeppelin Community <[email protected]>"]
Expand Down
8 changes: 4 additions & 4 deletions packages/access/src/accesscontrol/accesscontrol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub mod AccessControlComponent {
use openzeppelin_introspection::src5::SRC5Component;
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::storage::Map;
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};

#[storage]
struct Storage {
AccessControl_role_admin: Map<felt252, felt252>,
AccessControl_role_member: Map<(felt252, ContractAddress), bool>,
pub struct Storage {
pub AccessControl_role_admin: Map<felt252, felt252>,
pub AccessControl_role_member: Map<(felt252, ContractAddress), bool>,
}

#[event]
Expand Down
7 changes: 4 additions & 3 deletions packages/access/src/ownable/ownable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ pub mod OwnableComponent {
use crate::ownable::interface;
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

#[storage]
struct Storage {
Ownable_owner: ContractAddress,
Ownable_pending_owner: ContractAddress
pub struct Storage {
pub Ownable_owner: ContractAddress,
pub Ownable_pending_owner: ContractAddress
}

#[event]
Expand Down
22 changes: 11 additions & 11 deletions packages/access/src/tests/mocks/accesscontrol_mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ pub(crate) mod DualCaseAccessControlMock {
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
accesscontrol: AccessControlComponent::Storage,
pub accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -59,11 +59,11 @@ pub(crate) mod SnakeAccessControlMock {
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
accesscontrol: AccessControlComponent::Storage,
pub accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage,
pub src5: SRC5Component::Storage,
}

#[event]
Expand Down Expand Up @@ -104,11 +104,11 @@ pub(crate) mod CamelAccessControlMock {


#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
accesscontrol: AccessControlComponent::Storage,
pub accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -138,7 +138,7 @@ pub(crate) mod SnakeAccessControlPanicMock {
use starknet::ContractAddress;

#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down Expand Up @@ -183,7 +183,7 @@ pub(crate) mod CamelAccessControlPanicMock {
use starknet::ContractAddress;

#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[starknet::contract]
pub(crate) mod NonImplementingMock {
#[storage]
struct Storage {}
pub struct Storage {}

#[external(v0)]
fn nope(self: @ContractState) -> bool {
Expand Down
21 changes: 11 additions & 10 deletions packages/access/src/tests/mocks/ownable_mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub(crate) mod DualCaseOwnableMock {
impl InternalImpl = OwnableComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
ownable: OwnableComponent::Storage
pub ownable: OwnableComponent::Storage
}

#[event]
Expand Down Expand Up @@ -40,9 +40,9 @@ pub(crate) mod SnakeOwnableMock {
impl InternalImpl = OwnableComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
ownable: OwnableComponent::Storage
pub ownable: OwnableComponent::Storage
}

#[event]
Expand All @@ -61,6 +61,7 @@ pub(crate) mod SnakeOwnableMock {
#[starknet::contract]
pub(crate) mod CamelOwnableMock {
use crate::ownable::OwnableComponent;
use crate::ownable::interface::IOwnable;
use starknet::ContractAddress;

component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
Expand All @@ -71,9 +72,9 @@ pub(crate) mod CamelOwnableMock {
impl InternalImpl = OwnableComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
ownable: OwnableComponent::Storage
pub ownable: OwnableComponent::Storage
}

#[event]
Expand All @@ -93,7 +94,7 @@ pub(crate) mod CamelOwnableMock {
impl ExternalImpl of ExternalTrait {
#[external(v0)]
fn owner(self: @ContractState) -> ContractAddress {
self.ownable.Ownable_owner.read()
self.ownable.owner()
}
}
}
Expand All @@ -104,7 +105,7 @@ pub(crate) mod SnakeOwnablePanicMock {
use starknet::ContractAddress;

#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down Expand Up @@ -133,7 +134,7 @@ pub(crate) mod CamelOwnablePanicMock {
use starknet::ContractAddress;

#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down Expand Up @@ -169,7 +170,7 @@ pub(crate) mod DualCaseTwoStepOwnableMock {
impl InternalImpl = OwnableComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
ownable: OwnableComponent::Storage
}
Expand Down
1 change: 1 addition & 0 deletions packages/access/src/tests/test_ownable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::tests::mocks::ownable_mocks::DualCaseOwnableMock;
use openzeppelin_test_common::ownable::OwnableSpyHelpers;
use openzeppelin_testing::constants::{ZERO, OTHER, OWNER, RECIPIENT};
use snforge_std::{spy_events, test_address, start_cheat_caller_address};
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

//
// Setup
Expand Down
1 change: 1 addition & 0 deletions packages/access/src/tests/test_ownable_twostep.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use openzeppelin_testing::constants::{ZERO, OWNER, OTHER, NEW_OWNER};
use openzeppelin_testing::events::EventSpyExt;
use snforge_std::{EventSpy, spy_events, start_cheat_caller_address, test_address};
use starknet::ContractAddress;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

//
// Setup
Expand Down
5 changes: 3 additions & 2 deletions packages/account/src/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ pub mod AccountComponent {
use starknet::get_caller_address;
use starknet::get_contract_address;
use starknet::get_tx_info;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

#[storage]
struct Storage {
Account_public_key: felt252
pub struct Storage {
pub Account_public_key: felt252
}

#[event]
Expand Down
5 changes: 3 additions & 2 deletions packages/account/src/eth_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ pub mod EthAccountComponent {
use starknet::get_caller_address;
use starknet::get_contract_address;
use starknet::get_tx_info;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

#[storage]
struct Storage {
EthAccount_public_key: EthPublicKey
pub struct Storage {
pub EthAccount_public_key: EthPublicKey
}

#[event]
Expand Down
22 changes: 11 additions & 11 deletions packages/account/src/tests/mocks/account_mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub(crate) mod DualCaseAccountMock {
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
account: AccountComponent::Storage,
pub account: AccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -64,11 +64,11 @@ pub(crate) mod SnakeAccountMock {
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
account: AccountComponent::Storage,
pub account: AccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -108,11 +108,11 @@ pub(crate) mod CamelAccountMock {
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
account: AccountComponent::Storage,
pub account: AccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -153,7 +153,7 @@ pub(crate) mod CamelAccountMock {
#[starknet::contract]
pub(crate) mod SnakeAccountPanicMock {
#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down Expand Up @@ -190,7 +190,7 @@ pub(crate) mod SnakeAccountPanicMock {
#[starknet::contract]
pub(crate) mod CamelAccountPanicMock {
#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down
22 changes: 11 additions & 11 deletions packages/account/src/tests/mocks/eth_account_mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pub(crate) mod DualCaseEthAccountMock {
impl EthAccountInternalImpl = EthAccountComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
eth_account: EthAccountComponent::Storage,
pub eth_account: EthAccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -60,11 +60,11 @@ pub(crate) mod SnakeEthAccountMock {
impl EthAccountInternalImpl = EthAccountComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
eth_account: EthAccountComponent::Storage,
pub eth_account: EthAccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -103,11 +103,11 @@ pub(crate) mod CamelEthAccountMock {
impl EthAccountInternalImpl = EthAccountComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
pub struct Storage {
#[substorage(v0)]
eth_account: EthAccountComponent::Storage,
pub eth_account: EthAccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
pub src5: SRC5Component::Storage
}

#[event]
Expand Down Expand Up @@ -152,7 +152,7 @@ pub(crate) mod SnakeEthAccountPanicMock {
use starknet::secp256_trait::Secp256Trait;

#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down Expand Up @@ -193,7 +193,7 @@ pub(crate) mod CamelEthAccountPanicMock {
use starknet::secp256_trait::Secp256Trait;

#[storage]
struct Storage {}
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[starknet::contract]
pub(crate) mod NonImplementingMock {
#[storage]
struct Storage {}
pub struct Storage {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if we make empty storage structs not public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes much of a difference, right? But it might be easy to overlook adding the pub keyword if we add some field to it. I can remove all pub from all empty storage structs if you feel strongly about this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes much of a difference, right?

Yeahhh this really just occurs with mocks, right? No strong opinions on this. I think it's okay as is


#[external(v0)]
fn nope(self: @ContractState) -> bool {
Expand Down
5 changes: 3 additions & 2 deletions packages/account/src/tests/mocks/simple_mock.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ pub(crate) trait ISimpleMock<TContractState> {

#[starknet::contract]
pub(crate) mod SimpleMock {
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
#[storage]
struct Storage {
balance: felt252,
pub struct Storage {
pub balance: felt252,
}

#[abi(embed_v0)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[starknet::contract]
pub(crate) mod NonImplementingMock {
#[storage]
struct Storage {}
pub struct Storage {}

#[external(v0)]
fn nope(self: @ContractState) -> bool {
Expand Down
Loading