Skip to content

Commit

Permalink
Revert "Revert "Revert "Merge pull request ProjectOpenSea#505 from Pr…
Browse files Browse the repository at this point in the history
…ojectOpenSea/token-transferrer-comment-pass"""

This reverts commit 8cd4bbe.
  • Loading branch information
mrriteshranjan committed Jun 20, 2022
1 parent c42fd54 commit ca34e5a
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions contracts/lib/TokenTransferrer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ import {

import { ConduitBatch1155Transfer } from "../conduit/lib/ConduitStructs.sol";

/**
* @title TokenTransferrer
* @author 0age
* @custom:coauthor d1ll0n
* @custom:coauthor transmissions11
* @notice TokenTransferrer is a library for performing optimized ERC20, ERC721,
* ERC1155, and batch ERC1155 transfers, used by both Seaport as well as
* by conduits deployed by the ConduitController. Use great caution when
* considering these functions for use in other codebases, as there are
* significant side effects and edge cases that need to be thoroughly
* understood and carefully addressed.
*/
contract TokenTransferrer is TokenTransferrerErrors {
/**
* @dev Internal function to transfer ERC20 tokens from a given originator
Expand Down Expand Up @@ -52,11 +40,6 @@ contract TokenTransferrer is TokenTransferrerErrors {
mstore(ERC20_transferFrom_amount_ptr, amount)

// Make call & copy up to 32 bytes of return data to scratch space.
// Scratch space does not need to be cleared ahead of time, as the
// subsequent check will ensure that either at least a full word of
// return data is received (in which case it will be overwritten) or
// that no data is received (in which case scratch space will be
// ignored) on a successful call to the given token.
let callStatus := call(
gas(),
token,
Expand All @@ -79,8 +62,8 @@ contract TokenTransferrer is TokenTransferrerErrors {
callStatus
)

// Handle cases where either the transfer failed or no data was
// returned. Group these, as most transfers will succeed with data.
// If the transfer failed or it returned nothing:
// Group these because they should be uncommon.
// Equivalent to `or(iszero(success), iszero(returndatasize()))`
// but after it's inverted for JUMPI this expression is cheaper.
if iszero(and(success, iszero(iszero(returndatasize())))) {
Expand Down Expand Up @@ -207,14 +190,14 @@ contract TokenTransferrer is TokenTransferrerErrors {
)
}

// Otherwise, revert with error about token not having code:
// Otherwise revert with error about token not having code:
mstore(NoContract_error_sig_ptr, NoContract_error_signature)
mstore(NoContract_error_token_ptr, token)
revert(NoContract_error_sig_ptr, NoContract_error_length)
}

// Otherwise, the token just returned no data despite the call
// having succeeded; no need to optimize for this as it's not
// Otherwise the token just returned nothing but otherwise
// succeeded; no need to optimize for this as it's not
// technically ERC20 compliant.
}

Expand Down Expand Up @@ -764,8 +747,6 @@ contract TokenTransferrer is TokenTransferrerErrors {

// Reset the free memory pointer to the default value; memory must
// be assumed to be dirtied and not reused from this point forward.
// Also note that the zero slot is not reset to zero, meaning empty
// arrays cannot be safely created or utilized until it is restored.
mstore(FreeMemoryPointerSlot, DefaultFreeMemoryPointer)
}
}
Expand Down

0 comments on commit ca34e5a

Please sign in to comment.