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

Rename _msgSender #280

Merged
merged 2 commits into from
May 14, 2022
Merged
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
33 changes: 14 additions & 19 deletions contracts/ERC721A.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ contract ERC721A is IERC721A {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();

if (_msgSender() != owner) if(!isApprovedForAll(owner, _msgSender())) {
if (_erc721aMsgSender() != owner) if(!isApprovedForAll(owner, _erc721aMsgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}

Expand All @@ -238,10 +238,10 @@ contract ERC721A is IERC721A {
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
if (operator == _msgSender()) revert ApproveToCaller();
if (operator == _erc721aMsgSender()) revert ApproveToCaller();

_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
_operatorApprovals[_erc721aMsgSender()][operator] = approved;
emit ApprovalForAll(_erc721aMsgSender(), operator, approved);
}

/**
Expand Down Expand Up @@ -418,9 +418,9 @@ contract ERC721A is IERC721A {

if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();

bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
bool isApprovedOrOwner = (_erc721aMsgSender() == from ||
isApprovedForAll(from, _erc721aMsgSender()) ||
getApproved(tokenId) == _erc721aMsgSender());

if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
Expand Down Expand Up @@ -482,9 +482,9 @@ contract ERC721A is IERC721A {
address from = prevOwnership.addr;

if (approvalCheck) {
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
bool isApprovedOrOwner = (_erc721aMsgSender() == from ||
isApprovedForAll(from, _erc721aMsgSender()) ||
getApproved(tokenId) == _erc721aMsgSender());

if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
Expand Down Expand Up @@ -546,7 +546,7 @@ contract ERC721A is IERC721A {
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data)
try ERC721A__IERC721Receiver(to).onERC721Received(_erc721aMsgSender(), from, tokenId, _data)
returns (bytes4 retval) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
Expand Down Expand Up @@ -607,18 +607,13 @@ contract ERC721A is IERC721A {

/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSender() internal view virtual returns (address) {
function _erc721aMsgSender() internal view virtual returns (address) {
return msg.sender;
}

/**
* @dev Returns the message data (defaults to `msg.data`).
*/
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}

/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
Expand Down