Skip to content

Commit f44cc2a

Browse files
committed
chore: code improvements
1 parent f71b02d commit f44cc2a

File tree

3 files changed

+17
-42
lines changed

3 files changed

+17
-42
lines changed

contracts/src/token/erc20/interface.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Solidity Interface of the ERC-20 token.
2-
pub use interface::*;
2+
pub use token::*;
33

4-
mod interface {
4+
mod token {
55
#![allow(missing_docs)]
66
#![cfg_attr(coverage_nightly, coverage(off))]
77

contracts/src/token/erc721/extensions/wrapper.rs

+13-38
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@ pub trait IErc721Wrapper {
8383
///
8484
/// * [`Error::Erc721FailedOperation`] - If the underlying token is not an
8585
/// ERC-721 contract, or the contract fails to execute the call.
86-
///
87-
/// # Examples
88-
///
89-
/// ```rust,ignore
90-
/// fn deposit_for(&mut self, account: Address, token_ids: Vec<U256>) -> Result<bool, Error> {
91-
/// self.erc721_wrapper.deposit_for(account, token_ids, &mut self.erc721)
92-
/// }
93-
/// ```
9486
fn deposit_for(
9587
&mut self,
9688
account: Address,
@@ -114,14 +106,6 @@ pub trait IErc721Wrapper {
114106
/// [`Erc721`] contract, or the contract fails to execute the call.
115107
/// * [`Error::Erc721`] - If the wrapped token for `token_id` does not
116108
/// exist.
117-
///
118-
/// # Examples
119-
///
120-
/// ```rust,ignore
121-
/// fn withdraw_to(&mut self, account: Address, token_ids: Vec<U256>) -> Result<bool, Error> {
122-
/// self.erc721_wrapper.withdraw_to(account, token_ids, &mut self.erc721)
123-
/// }
124-
/// ```
125109
fn withdraw_to(
126110
&mut self,
127111
account: Address,
@@ -145,13 +129,6 @@ pub trait IErc721Wrapper {
145129
///
146130
/// * [`Error::UnsupportedToken`] - If `msg::sender()` is not the underlying
147131
/// token.
148-
///
149-
/// # Examples
150-
///
151-
/// ```rust,ignore
152-
/// fn on_erc721_received(&mut self, operator: Address, from: Address, token_id: U256, data: Bytes) -> Result<FixedBytes<4>, Error> {
153-
/// self.erc721_wrapper.on_erc721_received(operator, from, token_id, data, &mut self.erc721)
154-
/// }
155132
fn on_erc721_received(
156133
&mut self,
157134
operator: Address,
@@ -166,14 +143,6 @@ pub trait IErc721Wrapper {
166143
/// # Arguments
167144
///
168145
/// * `&self` - Read access to the contract's state.
169-
///
170-
/// # Examples
171-
///
172-
/// ```rust,ignore
173-
/// fn underlying(&self) -> Address {
174-
/// self.erc721_wrapper.underlying()
175-
/// }
176-
/// ```
177146
fn underlying(&self) -> Address;
178147
}
179148

@@ -229,8 +198,10 @@ impl IErc721Wrapper for Erc721Wrapper {
229198
let underlying = Erc721Interface::new(self.underlying());
230199

231200
for token_id in token_ids {
232-
// Setting the `auth` argument enables the `_is_authorized` check which verifies that the token exists
233-
// (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
201+
// Setting the `auth` argument enables the `_is_authorized` check
202+
// which verifies that the token exists (from != 0).
203+
// Therefore, it is not needed to verify that the return value is
204+
// not 0 here.
234205
erc721._update(Address::ZERO, token_id, sender)?;
235206
underlying
236207
.safe_transfer_from(
@@ -255,7 +226,7 @@ impl IErc721Wrapper for Erc721Wrapper {
255226
_operator: Address,
256227
from: Address,
257228
token_id: U256,
258-
data: Bytes,
229+
_data: Bytes,
259230
erc721: &mut Erc721,
260231
) -> Result<FixedBytes<4>, Error> {
261232
let sender = msg::sender();
@@ -265,7 +236,7 @@ impl IErc721Wrapper for Erc721Wrapper {
265236
}));
266237
}
267238

268-
erc721._safe_mint(from, token_id, &data)?;
239+
erc721._safe_mint(from, token_id, &vec![].into())?;
269240

270241
Ok(RECEIVER_FN_SELECTOR.into())
271242
}
@@ -284,6 +255,7 @@ impl Erc721Wrapper {
284255
/// * `&mut self` - Write access to the contract's state.
285256
/// * `account` - The account to mint tokens to.
286257
/// * `token_id` - A mutable reference to the Erc20 contract.
258+
/// * `erc721` - Write access to an [`Erc721`] contract.
287259
///
288260
/// # Errors
289261
///
@@ -406,8 +378,9 @@ mod tests {
406378
assert_eq!(contract.sender(alice).underlying(), erc721_address);
407379
}
408380

381+
// TODO: motsu should revert on calling a function that doesn't exist at
382+
// specified address.
409383
#[motsu::test]
410-
// TODO: motsu should not panic on this test
411384
#[ignore]
412385
fn deposit_for_reverts_when_unsupported_token(
413386
contract: Contract<Erc721WrapperTestExample>,
@@ -423,7 +396,7 @@ mod tests {
423396
let err = contract
424397
.sender(alice)
425398
.deposit_for(alice, token_ids.clone())
426-
.motsu_expect_err("should return Error::InvalidUnderlying");
399+
.motsu_expect_err("should return Error::UnsupportedToken");
427400

428401
assert!(matches!(
429402
err,
@@ -776,8 +749,10 @@ mod tests {
776749
);
777750
}
778751

752+
// TODO: motsu should revert on calling a function that doesn't exist at
753+
// specified address.
779754
#[motsu::test]
780-
#[ignore] // TODO: issue in motsu
755+
#[ignore]
781756
fn recover_reverts_when_invalid_token(
782757
contract: Contract<Erc721WrapperTestExample>,
783758
alice: Address,

contracts/src/token/erc721/interface.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Solidity Interface of the ERC-721 token.
2-
pub use interface::*;
2+
pub use token::*;
33

4-
mod interface {
4+
mod token {
55
#![allow(missing_docs)]
66
#![cfg_attr(coverage_nightly, coverage(off))]
77
use alloc::vec;

0 commit comments

Comments
 (0)