Skip to content

ref: remove Deref trait implementation #724

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

Merged
merged 2 commits into from
Jun 30, 2025
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed (Breaking)

- Remove implementation of `Deref<Target = Erc1155>` for `Erc1155Supply`, `Deref<Target = Erc721>` for `Erc721Consecutive`, and `Deref<Target = Ownable>` for `Ownable2Step`. #724

## [v0.2.0] - 2025-06-20

> **Heads-up:** this is the production release after four pre-releases
Expand Down
15 changes: 0 additions & 15 deletions contracts/src/access/ownable_two_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! available.

use alloc::{vec, vec::Vec};
use core::ops::{Deref, DerefMut};

use alloy_primitives::{Address, FixedBytes};
use openzeppelin_stylus_proc::interface_id;
Expand Down Expand Up @@ -58,20 +57,6 @@ pub struct Ownable2Step {
pub(crate) pending_owner: StorageAddress,
}

impl Deref for Ownable2Step {
type Target = Ownable;

fn deref(&self) -> &Self::Target {
&self.ownable
}
}

impl DerefMut for Ownable2Step {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.ownable
}
}

/// Interface for an [`Ownable2Step`] contract.
#[interface_id]
pub trait IOwnable2Step {
Expand Down
15 changes: 0 additions & 15 deletions contracts/src/token/erc1155/extensions/supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//! deployed contract.

use alloc::{vec, vec::Vec};
use core::ops::{Deref, DerefMut};

use alloy_primitives::{Address, FixedBytes, U256};
use openzeppelin_stylus_proc::interface_id;
Expand Down Expand Up @@ -42,20 +41,6 @@ pub struct Erc1155Supply {
pub(crate) total_supply_all: StorageU256,
}

impl Deref for Erc1155Supply {
type Target = Erc1155;

fn deref(&self) -> &Self::Target {
&self.erc1155
}
}

impl DerefMut for Erc1155Supply {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.erc1155
}
}

/// Required interface of a [`Erc1155Supply`] contract.
#[interface_id]
pub trait IErc1155Supply: IErc165 {
Expand Down
15 changes: 0 additions & 15 deletions contracts/src/token/erc721/extensions/consecutive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//! [ERC]: https://eips.ethereum.org/EIPS/eip-2309

use alloc::{vec, vec::Vec};
use core::ops::{Deref, DerefMut};

use alloy_primitives::{aliases::U96, uint, Address, FixedBytes, U256};
use stylus_sdk::{abi::Bytes, call::MethodError, evm, msg, prelude::*};
Expand Down Expand Up @@ -198,20 +197,6 @@ pub struct Erc721Consecutive {
pub max_batch_size: StorageU96,
}

impl Deref for Erc721Consecutive {
type Target = Erc721;

fn deref(&self) -> &Self::Target {
&self.erc721
}
}

impl DerefMut for Erc721Consecutive {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.erc721
}
}

/// NOTE: Implementation of [`TopLevelStorage`] to be able use `&mut self` when
/// calling other contracts and not `&mut (impl TopLevelStorage +
/// BorrowMut<Self>)`. Should be fixed in the future by the Stylus team.
Expand Down
2 changes: 1 addition & 1 deletion examples/ownable-two-step/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl IErc20 for Ownable2StepExample {
to: Address,
value: U256,
) -> Result<bool, Self::Error> {
self.ownable.only_owner()?;
self.ownable.ownable.only_owner()?;
Ok(self.erc20.transfer(to, value)?)
}

Expand Down
Loading