Skip to content

Commit 4f37c04

Browse files
authored
Update ERC1155.sol
1 parent 0de8004 commit 4f37c04

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contracts/token/ERC1155/ERC1155.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IER
9595
return _operatorApprovals[account][operator];
9696
}
9797

98-
/// @inheritdoc IERC1155
99-
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
98+
function _checkAuthorized(address from) internal view {
10099
address sender = _msgSender();
101100
if (from != sender && !isApprovedForAll(from, sender)) {
102101
revert ERC1155MissingApprovalForAll(sender, from);
103102
}
103+
}
104+
105+
/// @inheritdoc IERC1155
106+
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
107+
_checkAuthorized(from);
104108
_safeTransferFrom(from, to, id, value, data);
105109
}
106110

@@ -112,13 +116,9 @@ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IER
112116
uint256[] memory values,
113117
bytes memory data
114118
) public virtual {
115-
address sender = _msgSender();
116-
if (from != sender && !isApprovedForAll(from, sender)) {
117-
revert ERC1155MissingApprovalForAll(sender, from);
118-
}
119+
_checkAuthorized(from);
119120
_safeBatchTransferFrom(from, to, ids, values, data);
120121
}
121-
122122
/**
123123
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
124124
* (or `to`) is the zero address.

0 commit comments

Comments
 (0)