Skip to content
Merged
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Decoupled openzeppelin_utils version from the umbrella package (#1531)
- Removed openzeppelin_governance dependency on openzeppelin_account (#1531)
- Removed openzeppelin_token dependency on openzeppelin_account (#1531)

### Changed (Breaking)

- Removed `execute_single_call`, `execute_calls` and `assert_valid_signature` from openzeppelin_account::utils (#1531)

## 3.0.0-alpha.2 (2025-09-10)

### Added
Expand Down
6 changes: 2 additions & 4 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ name = "openzeppelin_governance"
version = "3.0.0-alpha.2"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_interfaces",
"openzeppelin_introspection",
"openzeppelin_test_common",
Expand All @@ -76,7 +75,7 @@ dependencies = [

[[package]]
name = "openzeppelin_interfaces"
version = "2.1.0"
version = "2.1.0-alpha.0"
dependencies = [
"snforge_std",
]
Expand Down Expand Up @@ -161,7 +160,6 @@ name = "openzeppelin_token"
version = "3.0.0-alpha.2"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_interfaces",
"openzeppelin_introspection",
"openzeppelin_test_common",
Expand All @@ -181,7 +179,7 @@ dependencies = [

[[package]]
name = "openzeppelin_utils"
version = "3.0.0-alpha.2"
version = "3.1.0-alpha.0"
dependencies = [
"openzeppelin_interfaces",
"openzeppelin_test_common",
Expand Down
4 changes: 2 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ keywords = [
]

[workspace.dependencies]
assert_macros = "2.12.0"
starknet = "2.12.0"
assert_macros = "2.12.2"
starknet = "2.12.2"
snforge_std = "0.50.0"

[dependencies]
Expand Down
13 changes: 13 additions & 0 deletions docs/modules/ROOT/pages/api/utilities.adoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
= Utilities

include::../utils/_common.adoc[]

:deploy_syscall: link:https://docs.starknet.io/architecture-and-concepts/smart-contracts/system-calls-cairo1/#deploy[deploy_syscall]
:eip6372: link:https://eips.ethereum.org/EIPS/eip-6372[EIP-6372]

This crate provides miscellaneous components and libraries containing utility functions to handle common tasks.

[IMPORTANT]
====
This API reference is for the `openzeppelin_utils` package version `v{current_openzeppelin_utils_version}`.

The `openzeppelin` package is an umbrella (meta) package that aggregates all library subpackages. Prior to v3.x, the umbrella and its subpackages were
versioned in lockstep—their versions always matched. Starting with v3.x, following the introduction of `openzeppelin_interfaces`, the umbrella is
versioned independently from some of the subpackages.

See the xref:../index.adoc#versioning_of_the_sub_packages[Versioning of the sub-packages] section for more information.
====

== Core

[.contract]
Expand Down
18 changes: 8 additions & 10 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ before proceeding, and run the following command to check that the installation
----
$ scarb --version

scarb 2.12.0 (639d0a65e 2025-08-04)
cairo: 2.12.0 (https://crates.io/crates/cairo-lang-compiler/2.12.0)
scarb 2.12.2 (dc0dbfd50 2025-09-15)
cairo: 2.12.2 (https://crates.io/crates/cairo-lang-compiler/2.12.2)
sierra: 1.7.0
----

Expand Down Expand Up @@ -59,13 +59,9 @@ Scarb.toml src

[IMPORTANT]
====
The `openzeppelin` package is an umbrella package that includes all the packages in the library.
Before version `3.x.x`, the `openzeppelin` and its sub-packages
were versioned together meaning that the version of the `openzeppelin`
package was the same as the version of the sub-packages.

Starting from version `3.x.x`, with the introduction of the `openzeppelin_interfaces` package,
the `openzeppelin` package is versioned independently from the sub-packages.
The `openzeppelin` package is an umbrella (meta) package that aggregates all library subpackages. Prior to v3.x, the umbrella and its subpackages were
versioned in lockstep—their versions always matched. Starting with v3.x, following the introduction of `openzeppelin_interfaces`, the umbrella is
versioned independently from some of the subpackages.

See the {versioning} section for more information.
====
Expand Down Expand Up @@ -109,7 +105,9 @@ openzeppelin_presets = "3.0.0-alpha.2"
openzeppelin_security = "3.0.0-alpha.2"
openzeppelin_token = "3.0.0-alpha.2"
openzeppelin_upgrades = "3.0.0-alpha.2"
openzeppelin_utils = "3.0.0-alpha.2"

openzeppelin_interfaces = "{current_openzeppelin_interfaces_version}"
openzeppelin_utils = "{current_openzeppelin_utils_version}"
----

== Basic usage
Expand Down
3 changes: 2 additions & 1 deletion docs/modules/ROOT/pages/utils/_common.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
:immutable-config: xref:components.adoc#immutable_config[Immutable Component Config]

// Variables
:current_openzeppelin_interfaces_version: 2.1.0
:current_openzeppelin_interfaces_version: 2.1.0-alpha.0
:current_openzeppelin_utils_version: 3.1.0-alpha.0
3 changes: 2 additions & 1 deletion packages/account/src/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ pub mod AccountComponent {
use openzeppelin_introspection::src5::SRC5Component::{
InternalTrait as SRC5InternalTrait, SRC5Impl,
};
use openzeppelin_utils::execution::execute_single_call;
use starknet::account::Call;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
use crate::utils::{execute_single_call, is_tx_version_valid, is_valid_stark_signature};
use crate::utils::{is_tx_version_valid, is_valid_stark_signature};

#[storage]
pub struct Storage {
Expand Down
3 changes: 2 additions & 1 deletion packages/account/src/eth_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ pub mod EthAccountComponent {
use openzeppelin_introspection::src5::SRC5Component::{
InternalTrait as SRC5InternalTrait, SRC5Impl,
};
use openzeppelin_utils::execution::execute_single_call;
use starknet::SyscallResultTrait;
use starknet::account::Call;
use starknet::secp256_trait::Secp256PointTrait;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
use crate::utils::secp256_point::Secp256PointStorePacking;
use crate::utils::{execute_single_call, is_tx_version_valid, is_valid_eth_signature};
use crate::utils::{is_tx_version_valid, is_valid_eth_signature};

#[storage]
pub struct Storage {
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/extensions/src9/src9.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub mod SRC9Component {
use openzeppelin_introspection::src5::SRC5Component;
use openzeppelin_introspection::src5::SRC5Component::InternalTrait as SRC5InternalTrait;
use openzeppelin_utils::cryptography::snip12::{OffchainMessageHash, SNIP12Metadata};
use openzeppelin_utils::execution::{assert_valid_signature, execute_calls};
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
use crate::extensions::src9::snip12_utils::OutsideExecutionStructHash;
use crate::utils::{assert_valid_signature, execute_calls};

#[storage]
pub struct Storage {
Expand Down
1 change: 0 additions & 1 deletion packages/account/src/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ mod test_account;
mod test_eth_account;
mod test_secp256_point;
mod test_signature;
mod test_utils;
36 changes: 0 additions & 36 deletions packages/account/src/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,14 @@

pub mod secp256_point;
pub mod signature;
use openzeppelin_interfaces::accounts::{ISRC6Dispatcher, ISRC6DispatcherTrait};

pub use signature::{is_valid_eth_signature, is_valid_p256_signature, is_valid_stark_signature};
use starknet::account::Call;
use starknet::{ContractAddress, SyscallResultTrait};

pub const MIN_TRANSACTION_VERSION: u256 = 1;
pub const QUERY_OFFSET: u256 = 0x100000000000000000000000000000000;
// QUERY_OFFSET + TRANSACTION_VERSION
pub const QUERY_VERSION: u256 = 0x100000000000000000000000000000001;

/// Executes a list of calls and returns the return values.
pub fn execute_calls(calls: Span<Call>) -> Array<Span<felt252>> {
let mut res = array![];
for call in calls {
res.append(execute_single_call(call));
}
res
}

/// Executes a single call and returns the return value.
pub fn execute_single_call(call: @Call) -> Span<felt252> {
let Call { to, selector, calldata } = *call;
starknet::syscalls::call_contract_syscall(to, selector, calldata).unwrap_syscall()
}

/// Validates a signature using SRC6 `is_valid_signature` and asserts it's valid.
/// Checks both 'VALID' (starknet::VALIDATED) and true (1) for backwards compatibility.
pub fn assert_valid_signature(
signer: ContractAddress,
hash: felt252,
signature: Span<felt252>,
invalid_signature_error: felt252,
) {
let is_valid_signature_felt = ISRC6Dispatcher { contract_address: signer }
.is_valid_signature(hash, signature.into());

// Check either 'VALID' or true for backwards compatibility
let is_valid_signature = is_valid_signature_felt == starknet::VALIDATED
|| is_valid_signature_felt == 1;

assert(is_valid_signature, invalid_signature_error);
}

/// If the transaction is a simulation (version >= `QUERY_OFFSET`), it must be
/// greater than or equal to `QUERY_OFFSET` + `MIN_TRANSACTION_VERSION` to be considered valid.
/// Otherwise, it must be greater than or equal to `MIN_TRANSACTION_VERSION`.
Expand Down
1 change: 0 additions & 1 deletion packages/governance/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ starknet.workspace = true
openzeppelin_access = { path = "../access" }
openzeppelin_interfaces = { path = "../interfaces" }
openzeppelin_introspection = { path = "../introspection" }
openzeppelin_account = { path = "../account" }
openzeppelin_token = { path= "../token" }
openzeppelin_utils = { path = "../utils" }

Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/governor/governor.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ pub mod GovernorComponent {
use core::num::traits::Zero;
use core::pedersen::PedersenTrait;
use core::traits::PartialEq;
use openzeppelin_account::utils::assert_valid_signature;
use openzeppelin_interfaces::governor::{IGOVERNOR_ID, IGovernor, ProposalState};
use openzeppelin_introspection::src5::SRC5Component;
use openzeppelin_introspection::src5::SRC5Component::InternalImpl as SRC5InternalImpl;
use openzeppelin_utils::bytearray::ByteArrayExtTrait;
use openzeppelin_utils::cryptography::snip12::{OffchainMessageHash, SNIP12Metadata};
use openzeppelin_utils::execution::assert_valid_signature;
use starknet::account::Call;
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
use starknet::{ContractAddress, SyscallResultTrait};
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/votes/votes.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#[starknet::component]
pub mod VotesComponent {
use core::num::traits::Zero;
use openzeppelin_account::utils::assert_valid_signature;
use openzeppelin_interfaces::erc20::IERC20;
use openzeppelin_interfaces::erc721::IERC721;
use openzeppelin_interfaces::votes::IVotes;
Expand All @@ -34,6 +33,7 @@ pub mod VotesComponent {
use openzeppelin_token::erc721::ERC721Component;
use openzeppelin_utils::contract_clock::ERC6372Clock;
use openzeppelin_utils::cryptography::snip12::{OffchainMessageHash, SNIP12Metadata};
use openzeppelin_utils::execution::assert_valid_signature;
use openzeppelin_utils::nonces::NoncesComponent;
use openzeppelin_utils::nonces::NoncesComponent::InternalTrait as NoncesInternalTrait;
use openzeppelin_utils::structs::checkpoint::{Checkpoint, Trace, TraceTrait};
Expand Down
15 changes: 15 additions & 0 deletions packages/interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- markdownlint-disable MD024 -->

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.1.0-alpha.0 (2025-09-17)

### Added

- Moved interfaces, ABIs and dispatchers into `openzeppelin_interfaces` (#1463)
- Some structs and types that were defined inside interface files were also moved
2 changes: 1 addition & 1 deletion packages/interfaces/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[package]
name = "openzeppelin_interfaces"
version = "2.1.0"
version = "2.1.0-alpha.0"
readme = "README.md"
keywords = [
"openzeppelin",
Expand Down
1 change: 0 additions & 1 deletion packages/token/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ scarb.workspace = true
[dependencies]
starknet.workspace = true
openzeppelin_access = { path = "../access" }
openzeppelin_account = { path = "../account" }
openzeppelin_interfaces = { path = "../interfaces" }
openzeppelin_introspection = { path = "../introspection" }
openzeppelin_utils = { path = "../utils" }
Expand Down
2 changes: 1 addition & 1 deletion packages/token/src/erc20/erc20.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#[starknet::component]
pub mod ERC20Component {
use core::num::traits::{Bounded, Zero};
use openzeppelin_account::utils::assert_valid_signature;
use openzeppelin_interfaces::erc20 as interface;
use openzeppelin_interfaces::nonces::INonces;
use openzeppelin_interfaces::snip12::ISNIP12Metadata;
use openzeppelin_utils::cryptography::snip12::{
OffchainMessageHash, SNIP12Metadata, StarknetDomain, StructHash,
};
use openzeppelin_utils::execution::assert_valid_signature;
use openzeppelin_utils::nonces::NoncesComponent;
use openzeppelin_utils::nonces::NoncesComponent::InternalTrait as NoncesInternalTrait;
use starknet::ContractAddress;
Expand Down
18 changes: 18 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- markdownlint-disable MD024 -->

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 3.1.0-alpha.0 (2025-09-17)

### Added

- `execution` module including `execute_single_call`, `execute_calls` and `assert_valid_signature` (#1531)

### Changed

- Decoupled version from the umbrella package (#1531)
1 change: 1 addition & 0 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This crate provides components and libraries containing miscellaneous utilities.
- [`utils`](https://docs.openzeppelin.com/contracts-cairo/3.0.0-alpha.2/api/utilities#utils)
- [`cryptography`](https://docs.openzeppelin.com/contracts-cairo/3.0.0-alpha.2/api/utilities#cryptography)
- [`deployments`](https://docs.openzeppelin.com/contracts-cairo/3.0.0-alpha.2/api/utilities#deployments)
- [`execution`] (https://docs.openzeppelin.com/contracts-cairo/3.0.0-alpha.2/api/utilities#execution)
- [`math`](https://docs.openzeppelin.com/contracts-cairo/3.0.0-alpha.2/api/utilities#math)
- [`serde`](https://docs.openzeppelin.com/contracts-cairo/3.0.0-alpha.2/api/utilities#serde)

Expand Down
8 changes: 7 additions & 1 deletion packages/utils/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

[package]
name = "openzeppelin_utils"
version = "3.1.0-alpha.0"
readme = "README.md"
keywords = [
"openzeppelin",
Expand All @@ -9,7 +10,6 @@ keywords = [
"standards",
"utils"
]
version.workspace = true
edition.workspace = true
cairo-version.workspace = true
scarb-version.workspace = true
Expand Down Expand Up @@ -42,3 +42,9 @@ fuzzing = []
allowed-libfuncs-list.name = "experimental"
sierra = true
casm = false

[[test]]
name = "openzeppelin_utils_unittest"
build-external-contracts = [
"openzeppelin_test_common::mocks::account::DualCaseAccountMock",
]
Loading