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
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"lib/e2e-proc",
"examples/access-control",
"examples/ecdsa",
"examples/erc1967",
"examples/erc20",
"examples/erc20-permit",
"examples/erc20-flash-mint",
Expand All @@ -26,6 +27,7 @@ members = [
"examples/vesting-wallet",
"examples/ownable-two-step",
"examples/poseidon",
"examples/proxy",
"examples/pedersen",
"examples/basic/token",
"examples/basic/script",
Expand All @@ -37,6 +39,7 @@ default-members = [
"lib/e2e-proc",
"examples/access-control",
"examples/ecdsa",
"examples/erc1967",
"examples/erc20",
"examples/erc20-permit",
"examples/erc20-flash-mint",
Expand All @@ -55,6 +58,7 @@ default-members = [
"examples/vesting-wallet",
"examples/ownable-two-step",
"examples/poseidon",
"examples/proxy",
"examples/pedersen",
"examples/basic/token",
]
Expand Down
4 changes: 0 additions & 4 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
## Setup

1. Install [Docker].
1. Install the [Solidity Compiler] version `0.8.24`.
(NOTE: it is important to use this exact version to avoid compatibility issues).
1. Install toolchain providing `cargo` using [rustup].
1. Install the cargo stylus tool with `cargo install --force cargo-stylus`.

Expand All @@ -15,8 +13,6 @@ and retry installing the stylus tool.

[Docker]: https://docs.docker.com/engine/install/

[Solidity Compiler]: https://docs.soliditylang.org/en/v0.8.28/installing-solidity.html#linux-packages

[rustup]: https://rustup.rs/

## Testing
Expand Down
22 changes: 20 additions & 2 deletions contracts/src/proxy/beacon/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
//! Solidity Interface of `BeaconProxy`.
pub use beacon::*;

use alloy_primitives::Address;

mod proxy;
mod upgradeable;

pub use beacon::IBeaconInterface;
pub use proxy::BeaconProxy;
pub use upgradeable::{IUpgradeableBeacon, UpgradeableBeacon};

/// This is the interface that [BeaconProxy][BeaconProxy] expects of its beacon.

Check warning on line 12 in contracts/src/proxy/beacon/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

redundant explicit link target

Check warning on line 12 in contracts/src/proxy/beacon/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/mod.rs#L12

warning: item in documentation is missing backticks --> contracts/src/proxy/beacon/mod.rs:12:33 | 12 | /// This is the interface that [BeaconProxy][BeaconProxy] expects of its beacon. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 12 - /// This is the interface that [BeaconProxy][BeaconProxy] expects of its beacon. 12 + /// This is the interface that [`BeaconProxy`][BeaconProxy] expects of its beacon. |
Raw output
contracts/src/proxy/beacon/mod.rs:12:33:w:warning: item in documentation is missing backticks
  --> contracts/src/proxy/beacon/mod.rs:12:33
   |
12 | /// This is the interface that [BeaconProxy][BeaconProxy] expects of its beacon.
   |                                 ^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
12 - /// This is the interface that [BeaconProxy][BeaconProxy] expects of its beacon.
12 + /// This is the interface that [`BeaconProxy`][BeaconProxy] expects of its beacon.
   |


__END__
///
/// [BeaconProxy]: crate::proxy::beacon::BeaconProxy
pub trait IBeacon {
/// Must return an address that can be used as a delegate call target.
///
/// [`UpgradeableBeacon`] will check that this address is a contract.
fn implementation(&self) -> Result<Address, stylus_sdk::call::Error>;

Check warning on line 19 in contracts/src/proxy/beacon/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/mod.rs#L19

warning: docs for function returning `Result` missing `# Errors` section --> contracts/src/proxy/beacon/mod.rs:19:5 | 19 | fn implementation(&self) -> Result<Address, stylus_sdk::call::Error>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc = note: `-W clippy::missing-errors-doc` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::missing_errors_doc)]`
Raw output
contracts/src/proxy/beacon/mod.rs:19:5:w:warning: docs for function returning `Result` missing `# Errors` section
  --> contracts/src/proxy/beacon/mod.rs:19:5
   |
19 |     fn implementation(&self) -> Result<Address, stylus_sdk::call::Error>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
   = note: `-W clippy::missing-errors-doc` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::missing_errors_doc)]`


__END__
}

mod beacon {
#![allow(missing_docs)]
Expand All @@ -9,7 +27,7 @@

use stylus_sdk::prelude::sol_interface;
sol_interface! {
interface IBeacon {
interface IBeaconInterface {
function implementation() external view returns (address);
}
}
Expand Down
89 changes: 89 additions & 0 deletions contracts/src/proxy/beacon/proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//! This contract implements a proxy that gets the implementation address for
//! each call from an [UpgradeableBeacon][UpgradeableBeacon].

Check warning on line 2 in contracts/src/proxy/beacon/proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/proxy.rs#L2

warning: item in documentation is missing backticks --> contracts/src/proxy/beacon/proxy.rs:2:24 | 2 | //! each call from an [UpgradeableBeacon][UpgradeableBeacon]. | ^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown = note: `-W clippy::doc-markdown` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::doc_markdown)]` help: try | 2 - //! each call from an [UpgradeableBeacon][UpgradeableBeacon]. 2 + //! each call from an [`UpgradeableBeacon`][UpgradeableBeacon]. |
Raw output
contracts/src/proxy/beacon/proxy.rs:2:24:w:warning: item in documentation is missing backticks
 --> contracts/src/proxy/beacon/proxy.rs:2:24
  |
2 | //! each call from an [UpgradeableBeacon][UpgradeableBeacon].
  |                        ^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
  = note: `-W clippy::doc-markdown` implied by `-W clippy::pedantic`
  = help: to override `-W clippy::pedantic` add `#[allow(clippy::doc_markdown)]`
help: try
  |
2 - //! each call from an [UpgradeableBeacon][UpgradeableBeacon].
2 + //! each call from an [`UpgradeableBeacon`][UpgradeableBeacon].
  |


__END__
//!
//! The beacon address can only be set once during construction, and cannot be
//! changed afterwards. It is stored in an immutable variable to avoid
//! unnecessary storage reads, and also in the beacon storage slot specified by
//! [ERC-1967] so that it can be accessed externally.
//!
//! CAUTION: Since the beacon address can never be changed, you must ensure that
//! you either control the beacon, or trust the beacon to not upgrade the
//! implementation maliciously.
//!
//! IMPORTANT: Do not use the implementation logic to modify the beacon storage
//! slot. Doing so would leave the proxy in an inconsistent state where the
//! beacon storage slot does not match the beacon address.
//!
//! [UpgradeableBeacon]: crate::proxy::beacon::UpgradeableBeacon
//! [ERC-1967]: https://eips.ethereum.org/EIPS/eip-1967

use alloc::{vec, vec::Vec};

use alloy_primitives::Address;
use stylus_sdk::{abi::Bytes, prelude::*, storage::StorageAddress};

use crate::proxy::{
beacon::IBeaconInterface,
erc1967::{Erc1967Utils, Error},
IProxy,
};

/// State of an [`BeaconProxy`] token.
#[storage]
pub struct BeaconProxy {
beacon: StorageAddress,
}

/// 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.
unsafe impl TopLevelStorage for BeaconProxy {}

impl BeaconProxy {
/// Initializes the proxy with `beacon`.
///
/// If `data` is nonempty, it's used as data in a delegate call to the
/// implementation returned by the beacon. This will typically be an
/// encoded function call, and allows initializing the storage of the proxy
/// like a Solidity constructor.
///
/// # Arguments
///
/// * `&mut self` - Write access to the contract's state.
/// * `beacon` - The beacon address.
/// * `data` - The data to pass to the beacon.
///
/// # Errors
///
/// * [`Error::InvalidBeacon`] - If the beacon is not a contract with the
/// interface [IBeacon][IBeacon].

Check warning on line 59 in contracts/src/proxy/beacon/proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/proxy.rs#L59

warning: item in documentation is missing backticks --> contracts/src/proxy/beacon/proxy.rs:59:22 | 59 | /// interface [IBeacon][IBeacon]. | ^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 59 - /// interface [IBeacon][IBeacon]. 59 + /// interface [`IBeacon`][IBeacon]. |
Raw output
contracts/src/proxy/beacon/proxy.rs:59:22:w:warning: item in documentation is missing backticks
  --> contracts/src/proxy/beacon/proxy.rs:59:22
   |
59 |     ///   interface [IBeacon][IBeacon].
   |                      ^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
59 -     ///   interface [IBeacon][IBeacon].
59 +     ///   interface [`IBeacon`][IBeacon].
   |


__END__
/// * [`Error::NonPayable`] - If the data is empty and
/// [msg::value][msg_value] is not [`U256::ZERO`].

Check failure on line 61 in contracts/src/proxy/beacon/proxy.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unresolved link to `U256::ZERO`

Check warning on line 61 in contracts/src/proxy/beacon/proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/proxy.rs#L61

warning: item in documentation is missing backticks --> contracts/src/proxy/beacon/proxy.rs:61:12 | 61 | /// [msg::value][msg_value] is not [`U256::ZERO`]. | ^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 61 - /// [msg::value][msg_value] is not [`U256::ZERO`]. 61 + /// [`msg::value`][msg_value] is not [`U256::ZERO`]. |
Raw output
contracts/src/proxy/beacon/proxy.rs:61:12:w:warning: item in documentation is missing backticks
  --> contracts/src/proxy/beacon/proxy.rs:61:12
   |
61 |     ///   [msg::value][msg_value] is not [`U256::ZERO`].
   |            ^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
   |
61 -     ///   [msg::value][msg_value] is not [`U256::ZERO`].
61 +     ///   [`msg::value`][msg_value] is not [`U256::ZERO`].
   |


__END__
///
/// [msg_value]: stylus_sdk::msg::value
/// [IBeacon]: crate::proxy::beacon::IBeacon
pub fn constructor(
&mut self,
beacon: Address,
data: Bytes,
) -> Result<(), Error> {
Erc1967Utils::upgrade_beacon_to_and_call(self, beacon, data)?;
self.beacon.set(beacon);
Ok(())
}

/// Returns the beacon.
///
/// # Arguments
///
/// * `&self` - Read access to the contract's state.
pub fn get_beacon(&self) -> Address {

Check warning on line 80 in contracts/src/proxy/beacon/proxy.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/proxy.rs#L80

warning: this method could have a `#[must_use]` attribute --> contracts/src/proxy/beacon/proxy.rs:80:5 | 80 | pub fn get_beacon(&self) -> Address { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn get_beacon(&self) -> Address` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate = note: `-W clippy::must-use-candidate` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::must_use_candidate)]`
Raw output
contracts/src/proxy/beacon/proxy.rs:80:5:w:warning: this method could have a `#[must_use]` attribute
  --> contracts/src/proxy/beacon/proxy.rs:80:5
   |
80 |     pub fn get_beacon(&self) -> Address {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn get_beacon(&self) -> Address`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate
   = note: `-W clippy::must-use-candidate` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::must_use_candidate)]`


__END__
self.beacon.get()
}
}

impl IProxy for BeaconProxy {
fn implementation(&self) -> Result<Address, stylus_sdk::call::Error> {
IBeaconInterface::new(self.get_beacon()).implementation(self)
}
}
24 changes: 24 additions & 0 deletions contracts/src/proxy/beacon/upgradeable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use alloc::{vec, vec::Vec};

use stylus_sdk::{prelude::*, storage::StorageAddress};

use crate::{access::ownable::IOwnable, proxy::beacon::IBeacon};

/// This contract is used in conjunction with one or more instances of
/// [BeaconProxy][BeaconProxy] to determine their implementation contract, which

Check warning on line 8 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/upgradeable.rs#L8

warning: item in documentation is missing backticks --> contracts/src/proxy/beacon/upgradeable.rs:8:6 | 8 | /// [BeaconProxy][BeaconProxy] to determine their implementation contract, which | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 8 - /// [BeaconProxy][BeaconProxy] to determine their implementation contract, which 8 + /// [`BeaconProxy`][BeaconProxy] to determine their implementation contract, which |
Raw output
contracts/src/proxy/beacon/upgradeable.rs:8:6:w:warning: item in documentation is missing backticks
 --> contracts/src/proxy/beacon/upgradeable.rs:8:6
  |
8 | /// [BeaconProxy][BeaconProxy] to determine their implementation contract, which
  |      ^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
  |
8 - /// [BeaconProxy][BeaconProxy] to determine their implementation contract, which
8 + /// [`BeaconProxy`][BeaconProxy] to determine their implementation contract, which
  |


__END__
/// is where they will delegate all function calls.
///
/// An owner is able to change the implementation the beacon points to, thus
/// upgrading the proxies that use this beacon.
///
/// [BeaconProxy]: crate::proxy::beacon::BeaconProxy
pub trait IUpgradeableBeacon: IBeacon + IOwnable {}

/// State of an [`UpgradeableBeacon`] contract.
#[storage]
pub struct UpgradeableBeacon {

Check warning on line 19 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/beacon/upgradeable.rs#L19

warning: fields `implementation` and `owner` are never read --> contracts/src/proxy/beacon/upgradeable.rs:21:5 | 19 | pub struct UpgradeableBeacon { | ----------------- fields in this struct 20 | /// The address of the implementation contract. 21 | implementation: StorageAddress, | ^^^^^^^^^^^^^^ 22 | /// The address of the owner of the contract. 23 | owner: StorageAddress, | ^^^^^ | = note: `#[warn(dead_code)]` on by default
Raw output
contracts/src/proxy/beacon/upgradeable.rs:19:12:w:warning: fields `implementation` and `owner` are never read
  --> contracts/src/proxy/beacon/upgradeable.rs:21:5
   |
19 | pub struct UpgradeableBeacon {
   |            ----------------- fields in this struct
20 |     /// The address of the implementation contract.
21 |     implementation: StorageAddress,
   |     ^^^^^^^^^^^^^^
22 |     /// The address of the owner of the contract.
23 |     owner: StorageAddress,
   |     ^^^^^
   |
   = note: `#[warn(dead_code)]` on by default


__END__
/// The address of the implementation contract.
implementation: StorageAddress,

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / tests

fields `implementation` and `owner` are never read

Check warning on line 21 in contracts/src/proxy/beacon/upgradeable.rs

View workflow job for this annotation

GitHub Actions / tests

fields `implementation` and `owner` are never read
/// The address of the owner of the contract.
owner: StorageAddress,
}
56 changes: 52 additions & 4 deletions contracts/src/proxy/erc1967/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
//! Proxy Storage Slots and the events as defined in
//! the [ERC-1967].
//! This contract implements an upgradeable proxy. It is upgradeable because
//! calls are delegated to an implementation address that can be changed. This
//! address is stored in storage in the location specified by
//! [ERC-1967], so that it doesn't conflict with the storage layout of the
//! implementation behind the proxy.
//!
//! [ERC-1967]: https://eips.ethereum.org/EIPS/eip-1967
use alloc::{vec, vec::Vec};

use alloy_primitives::Address;
use stylus_sdk::{abi::Bytes, prelude::*};

use crate::proxy::IProxy;

//! [ERC-1967]: <https://eips.ethereum.org/EIPS/eip-1967>
pub mod proxy;
pub mod utils;

pub use sol::*;
pub use utils::{Erc1967Utils, Error};

#[cfg_attr(coverage_nightly, coverage(off))]
mod sol {
use alloy_sol_macro::sol;
Expand All @@ -27,3 +38,40 @@
event BeaconUpgraded(address indexed beacon);
}
}

/// State of an [`Erc1967Proxy`] token.
#[storage]
pub struct Erc1967Proxy;

/// 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.
unsafe impl TopLevelStorage for Erc1967Proxy {}

impl Erc1967Proxy {
/// Constructor.
///
/// # Arguments
///
/// * `&mut self` - Write access to the contract's state.
/// * `implementation` - Address of the implementation contract.
/// * `data` - Data to pass to the implementation contract.
pub fn constructor(

Check warning on line 59 in contracts/src/proxy/erc1967/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/proxy/erc1967/mod.rs#L59

warning: docs for function returning `Result` missing `# Errors` section --> contracts/src/proxy/erc1967/mod.rs:59:5 | 59 | / pub fn constructor( 60 | | &mut self, 61 | | implementation: Address, 62 | | data: Bytes, 63 | | ) -> Result<(), Error> { | |__________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
Raw output
contracts/src/proxy/erc1967/mod.rs:59:5:w:warning: docs for function returning `Result` missing `# Errors` section
  --> contracts/src/proxy/erc1967/mod.rs:59:5
   |
59 | /     pub fn constructor(
60 | |         &mut self,
61 | |         implementation: Address,
62 | |         data: Bytes,
63 | |     ) -> Result<(), Error> {
   | |__________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc


__END__
&mut self,
implementation: Address,
data: Bytes,
) -> Result<(), Error> {
Erc1967Utils::upgrade_to_and_call(implementation, data)
}
}

impl IProxy for Erc1967Proxy {
/**
* @dev This is a virtual function that should be overridden so it
* returns the address to which the fallback function and
* {_fallback} should delegate.
*/
fn implementation(&self) -> Result<Address, stylus_sdk::call::Error> {
Ok(Erc1967Utils::get_implementation())
}
}
23 changes: 0 additions & 23 deletions contracts/src/proxy/erc1967/proxy.rs

This file was deleted.

Loading
Loading