forked from xmas7/nft-art-marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProxyCall.sol
32 lines (27 loc) · 1.04 KB
/
ProxyCall.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Address.sol";
import "./interfaces/IProxyCall.sol";
/**
* @notice Forwards arbitrary calls to an external contract.
* @dev This is used so that the from address of the calling contract does not have
* any special permissions (e.g. ERC-20 transfer).
* Other return types and call structures may be added in the future.
*
* DO NOT approve this contract to transfer any ERC-20 or ERC-721, or grant any other permissions for another contract.
*/
contract ProxyCall is IProxyCall {
using Address for address;
function proxyCallAndReturnAddress(address externalContract, bytes calldata callData)
external
override
returns (address payable result)
{
bytes memory returnData = externalContract.functionCall(callData);
// Skip the length at the start of the bytes array and return the data, casted to an address
// solhint-disable-next-line no-inline-assembly
assembly {
result := mload(add(returnData, 32))
}
}
}