Skip to content

Commit

Permalink
cache transferValidator on stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Apr 1, 2024
1 parent da36ee1 commit fa28d22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/clones/ERC1155ContractMetadataCloneable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ contract ERC1155ContractMetadataCloneable is
) internal virtual override {
if (from != address(0) && to != address(0)) {
// Call the transfer validator if one is set.
if (_transferValidator != address(0)) {
address transferValidator = _transferValidator;
if (transferValidator != address(0)) {
for (uint256 i = 0; i < ids.length; i++) {
ITransferValidator1155(_transferValidator).validateTransfer(
ITransferValidator1155(transferValidator).validateTransfer(
msg.sender,
from,
to,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/ERC1155ContractMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ contract ERC1155ContractMetadata is
) internal virtual override {
if (from != address(0) && to != address(0)) {
// Call the transfer validator if one is set.
if (_transferValidator != address(0)) {
address transferValidator = _transferValidator;
if (transferValidator != address(0)) {
for (uint256 i = 0; i < ids.length; i++) {
ITransferValidator1155(_transferValidator).validateTransfer(
ITransferValidator1155(transferValidator).validateTransfer(
msg.sender,
from,
to,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/ERC721ContractMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ contract ERC721ContractMetadata is
) internal virtual override {
if (from != address(0) && to != address(0)) {
// Call the transfer validator if one is set.
if (_transferValidator != address(0)) {
ITransferValidator721(_transferValidator).validateTransfer(
address transferValidator = _transferValidator;
if (transferValidator != address(0)) {
ITransferValidator721(transferValidator).validateTransfer(
msg.sender,
from,
to,
Expand Down

0 comments on commit fa28d22

Please sign in to comment.