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

[Feature]: ERC721Wrapper extension #461

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions contracts/src/token/erc721/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod consecutive;
pub mod enumerable;
pub mod metadata;
pub mod uri_storage;
pub mod wrapper;

pub use burnable::IErc721Burnable;
pub use enumerable::{Erc721Enumerable, IErc721Enumerable};
Expand Down
133 changes: 133 additions & 0 deletions contracts/src/token/erc721/extensions/wrapper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
//! Extension of the ERC-721 token contract to support token wrapping.
//!
//! Users can deposit and withdraw an "underlying token" and receive a "wrapped
//! token" with a matching tokenId. This is useful in conjunction with other
//! modules.
use alloc::{vec, vec::Vec};

use alloy_primitives::{Address, U256};
use stylus_sdk::{
call::Call,
contract,
prelude::storage,
storage::{StorageAddress, TopLevelStorage},
stylus_proc::SolidityError,
};

use crate::token::{
erc721,
erc721::{ERC721IncorrectOwner, Erc721},
};

/// State of an [`Erc721Wrapper`] token.
#[storage]
pub struct Erc721Wrapper {
/// Erc721 contract storage.
pub _underlying: StorageAddress,
/// The ERC-721 token.
pub erc721: Erc721,
}

unsafe impl TopLevelStorage for Erc721Wrapper {}

pub use sol::*;
#[cfg_attr(coverage_nightly, coverage(off))]
mod sol {
use alloy_sol_macro::sol;

sol! {
/// The received ERC-721 token couldn't be wrapped.
#[derive(Debug)]
#[allow(missing_docs)]
error ERC721UnsupportedToken(uint256 token_id);
}
}

/// An [`Erc721Wrapper`] error.
#[derive(SolidityError, Debug)]
pub enum Error {
/// Error type from [`Erc721`] contract [`erc721::Error`].
Erc721(erc721::Error),
/// The received ERC-721 token couldn't be wrapped.
ERC721UnsupportedToken(ERC721UnsupportedToken),
}

pub use token::IErc721;
mod token {
#![allow(missing_docs)]
#![cfg_attr(coverage_nightly, coverage(off))]
use alloc::vec;

stylus_sdk::stylus_proc::sol_interface! {
/// Interface of the ERC-721 token.
interface IErc721 {
function ownerOf(uint256 token_id) external view returns (address);
}
}
}

impl Erc721Wrapper {
/// Allow a user to deposit underlying tokens and mint the corresponding
/// tokenIds.
pub fn deposit_for(
&mut self,
account: Address,

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:74:9 | 74 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:74:9:w:warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:74:9 | 74 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` __END__

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:74:9 | 74 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:74:9:w:warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:74:9 | 74 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` __END__

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `account`

Check warning on line 74 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `account`
token_ids: Vec<U256>,

Check warning on line 75 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:75:20 | 75 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:75:20:w:warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:75:20 | 75 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]` __END__

Check warning on line 75 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:75:20 | 75 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:75:20:w:warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:75:20 | 75 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]` __END__
) -> bool {
let length = token_ids.len();

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:77:13 | 77 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` | = note: `#[warn(unused_variables)]` on by default Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:77:13:w:warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:77:13 | 77 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` | = note: `#[warn(unused_variables)]` on by default __END__

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:77:13 | 77 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` | = note: `#[warn(unused_variables)]` on by default Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:77:13:w:warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:77:13 | 77 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` | = note: `#[warn(unused_variables)]` on by default __END__

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `length`

Check warning on line 77 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `length`

true
}

/// Allow a user to burn wrapped tokens and withdraw the corresponding
/// tokenIds of the underlying tokens.
pub fn withdraw_to(
&mut self,
account: Address,

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:86:9 | 86 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:86:9:w:warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:86:9 | 86 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` __END__

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:86:9 | 86 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:86:9:w:warning: unused variable: `account` --> contracts/src/token/erc721/extensions/wrapper.rs:86:9 | 86 | account: Address, | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_account` __END__

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `account`

Check warning on line 86 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `account`
token_ids: Vec<U256>,

Check warning on line 87 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:87:20 | 87 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:87:20:w:warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:87:20 | 87 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value __END__

Check warning on line 87 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:87:20 | 87 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:87:20:w:warning: this argument is passed by value, but not consumed in the function body --> contracts/src/token/erc721/extensions/wrapper.rs:87:20 | 87 | token_ids: Vec<U256>, | ^^^^^^^^^ help: consider changing the type to: `&[U256]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value __END__
) -> bool {
let length = token_ids.len();

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:89:13 | 89 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:89:13:w:warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:89:13 | 89 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` __END__

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:89:13 | 89 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:89:13:w:warning: unused variable: `length` --> contracts/src/token/erc721/extensions/wrapper.rs:89:13 | 89 | let length = token_ids.len(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_length` __END__

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `length`

Check warning on line 89 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / tests

unused variable: `length`

true
}

/// Returns the underlying token.
pub fn underlying(&self) -> Address {
self._underlying.get()

Check warning on line 96 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / beta / clippy

[clippy] reported by reviewdog 🐶 warning: used underscore-prefixed binding --> contracts/src/token/erc721/extensions/wrapper.rs:96:9 | 96 | self._underlying.get() | ^^^^^^^^^^^^^^^^ | note: binding is defined here --> contracts/src/token/erc721/extensions/wrapper.rs:26:5 | 26 | pub _underlying: StorageAddress, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding = note: `-W clippy::used-underscore-binding` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::used_underscore_binding)]` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:96:9:w:warning: used underscore-prefixed binding --> contracts/src/token/erc721/extensions/wrapper.rs:96:9 | 96 | self._underlying.get() | ^^^^^^^^^^^^^^^^ | note: binding is defined here --> contracts/src/token/erc721/extensions/wrapper.rs:26:5 | 26 | pub _underlying: StorageAddress, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding = note: `-W clippy::used-underscore-binding` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::used_underscore_binding)]` __END__

Check warning on line 96 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / stable / clippy

[clippy] reported by reviewdog 🐶 warning: used underscore-prefixed binding --> contracts/src/token/erc721/extensions/wrapper.rs:96:9 | 96 | self._underlying.get() | ^^^^^^^^^^^^^^^^ | note: binding is defined here --> contracts/src/token/erc721/extensions/wrapper.rs:26:5 | 26 | pub _underlying: StorageAddress, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding = note: `-W clippy::used-underscore-binding` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::used_underscore_binding)]` Raw Output: contracts/src/token/erc721/extensions/wrapper.rs:96:9:w:warning: used underscore-prefixed binding --> contracts/src/token/erc721/extensions/wrapper.rs:96:9 | 96 | self._underlying.get() | ^^^^^^^^^^^^^^^^ | note: binding is defined here --> contracts/src/token/erc721/extensions/wrapper.rs:26:5 | 26 | pub _underlying: StorageAddress, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding = note: `-W clippy::used-underscore-binding` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::used_underscore_binding)]` __END__
}
}

// ************** ERC-721 Internal **************

impl Erc721Wrapper {
fn _recover(
&mut self,
account: Address,
token_id: U256,
) -> Result<U256, Error> {
let underlying = IErc721::new(self.underlying());
let owner = match underlying.owner_of(Call::new_in(self), token_id) {
Ok(owner) => owner,
Err(e) => return Err(Error::Erc721(e.into())),
};
if owner != contract::address() {
return Err(erc721::Error::IncorrectOwner(ERC721IncorrectOwner {
sender: contract::address(),
token_id,
owner,
})
.into());
}
self.erc721._safe_mint(account, token_id, &vec![].into())?;
Ok(token_id)
}
}

#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};

Check warning on line 128 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unused imports: `Address`, `U256`, `address`, and `uint`

Check warning on line 128 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

unused imports: `Address`, `U256`, `address`, and `uint`

Check warning on line 128 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

unused imports: `Address`, `U256`, `address`, and `uint`

Check warning on line 128 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

unused imports: `Address`, `U256`, `address`, and `uint`
use stylus_sdk::msg;

Check warning on line 129 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unused import: `stylus_sdk::msg`

Check warning on line 129 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

unused import: `stylus_sdk::msg`

Check warning on line 129 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

unused import: `stylus_sdk::msg`

Check warning on line 129 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

unused import: `stylus_sdk::msg`

#[motsu::test]
fn recover(contract: Erc721Wrapper) {}

Check failure on line 132 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

cannot find type `Erc721Wrapper` in this scope

Check failure on line 132 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

cannot find type `Erc721Wrapper` in this scope

Check failure on line 132 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

cannot find type `Erc721Wrapper` in this scope

Check failure on line 132 in contracts/src/token/erc721/extensions/wrapper.rs

View workflow job for this annotation

GitHub Actions / ubuntu / nightly / coverage

cannot find type `Erc721Wrapper` in this scope
}
Loading