-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathExternalProxyCall.sol
36 lines (30 loc) · 1.12 KB
/
ExternalProxyCall.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
33
34
35
36
/*
MUSEE Protocol
*/
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "./interfaces/IProxyCall.sol";
/**
* @title Forwards arbitrary calls to an external contract.
* @notice DO NOT approve this contract to transfer any ERC-20 or ERC-721,
* or grant any other permissions for another 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.
*/
contract ExternalProxyCall is IProxyCall {
using AddressUpgradeable for address;
function proxyCallAndReturnAddress(address externalContract, bytes memory 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))
}
}
}