Skip to content

Commit f71b02d

Browse files
bidzyyys0xNeshi
andauthored
ref: apply suggestions from code review
Co-authored-by: Nenad <[email protected]>
1 parent af28a8f commit f71b02d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Diff for: contracts/src/token/erc721/extensions/wrapper.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ pub trait IErc721Wrapper {
8181
///
8282
/// # Errors
8383
///
84-
/// * [`Error::Erc721FailedOperation`] - If the underlying token is not a
85-
/// [`Erc721`] contract, or the contract fails to execute the call.
84+
/// * [`Error::Erc721FailedOperation`] - If the underlying token is not an
85+
/// ERC-721 contract, or the contract fails to execute the call.
8686
///
8787
/// # Examples
8888
///
@@ -154,7 +154,7 @@ pub trait IErc721Wrapper {
154154
/// }
155155
fn on_erc721_received(
156156
&mut self,
157-
_operator: Address,
157+
operator: Address,
158158
from: Address,
159159
token_id: U256,
160160
data: Bytes,
@@ -229,6 +229,8 @@ impl IErc721Wrapper for Erc721Wrapper {
229229
let underlying = Erc721Interface::new(self.underlying());
230230

231231
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.
232234
erc721._update(Address::ZERO, token_id, sender)?;
233235
underlying
234236
.safe_transfer_from(
@@ -496,15 +498,15 @@ mod tests {
496498
contract.wrapper.underlying.set(erc721_contract.address());
497499
});
498500

499-
for token_id in &token_ids {
501+
for &token_id in &token_ids {
500502
erc721_contract
501503
.sender(alice)
502-
._mint(alice, *token_id)
504+
._mint(alice, token_id)
503505
.motsu_expect("should mint {token_id} for {alice}");
504506

505507
erc721_contract
506508
.sender(alice)
507-
.approve(contract.address(), *token_id)
509+
.approve(contract.address(), token_id)
508510
.motsu_expect(
509511
"should approve {token_id} for {contract.address()}",
510512
);

Diff for: examples/erc721-wrapper/tests/mock/erc721.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ sol! {
1010
// SPDX-License-Identifier: MIT
1111
// Compatible with OpenZeppelin Contracts ^5.0.0
1212
contract ERC721Mock is ERC721 {
13-
constructor()
14-
ERC721("ERC721Mock", "MTK") {}
13+
constructor() ERC721("ERC721Mock", "MTK") {}
1514

1615
function safeMint(address to, uint256 tokenId) public {
1716
_safeMint(to, tokenId);

0 commit comments

Comments
 (0)