ExcessivelySafeCall

Git Source

Functions

excessivelySafeCall

Use when you really really really don't trust the called contract. This prevents the called contract from causing reversion of the caller in as many ways as we can.

The main difference between this and a solidity low-level call is that we limit the number of bytes that the callee can cause to be copied to caller memory. This prevents stupid things like malicious contracts returning 10,000,000 bytes causing a local OOG when copying to memory.

function excessivelySafeCall(address _target, uint256 _gas, uint256 _value, uint16 _maxCopy, bytes memory _calldata)
    internal
    returns (bool, bytes memory);

Parameters

NameTypeDescription
_targetaddressThe address to call
_gasuint256The amount of gas to forward to the remote contract
_valueuint256Value in wei to send to the account
_maxCopyuint16The maximum number of bytes of returndata to copy to memory.
_calldatabytesThe data to send to the remote contract

Returns

NameTypeDescription
<none>boolsuccess and returndata, as .call(). Returndata is capped to _maxCopy bytes.
<none>bytes

excessivelySafeStaticCall

Use when you really really really don't trust the called contract. This prevents the called contract from causing reversion of the caller in as many ways as we can.

The main difference between this and a solidity low-level call is that we limit the number of bytes that the callee can cause to be copied to caller memory. This prevents stupid things like malicious contracts returning 10,000,000 bytes causing a local OOG when copying to memory.

function excessivelySafeStaticCall(address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata)
    internal
    view
    returns (bool, bytes memory);

Parameters

NameTypeDescription
_targetaddressThe address to call
_gasuint256The amount of gas to forward to the remote contract
_maxCopyuint16The maximum number of bytes of returndata to copy to memory.
_calldatabytesThe data to send to the remote contract

Returns

NameTypeDescription
<none>boolsuccess and returndata, as .call(). Returndata is capped to _maxCopy bytes.
<none>bytes