Skip to content

Commit

Permalink
Rename _msgSender (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized authored May 14, 2022
1 parent 27c61b1 commit 45454d6
Showing 1 changed file with 14 additions and 19 deletions.
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

0 comments on commit 45454d6

Please sign in to comment.