// SPDX-License-Identifier: MITpragmasolidity 0.8.20;import {GelatoBytes} from"./GelatoBytes.sol";
libraryGelatoCallUtils{
usingGelatoBytesforbytes;
functionrevertingContractCall(address _contract,
bytesmemory _data,
stringmemory _errorMsg
) internalreturns (bytesmemory returndata) {
bool success;
(success, returndata) = _contract.call(_data);
// solhint-disable-next-line max-line-length// https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.sol#L177if (success) {
if (returndata.length==0) {
// only check isContract if the call was successful and the return data is empty// otherwise we already know that it was a contractrequire(
isContract(_contract),
string(abi.encodePacked(_errorMsg, "Call to non contract"))
);
}
} else {
returndata.revertWithError(_errorMsg);
}
}
// solhint-disable-next-line max-line-length// https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.sol#L36functionisContract(address account) internalviewreturns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0// for contracts in construction, since the code is only stored at the end// of the constructor execution.return account.code.length>0;
}
}
Contract Source Code
File 3 of 5: GelatoRelay1BalanceV2.sol
// SPDX-License-Identifier: MITpragmasolidity 0.8.20;import {IGelatoRelay1BalanceV2} from"./interfaces/IGelatoRelay1BalanceV2.sol";
import {IGelato1BalanceV2} from"./interfaces/IGelato1BalanceV2.sol";
import {GelatoCallUtils} from"./lib/GelatoCallUtils.sol";
/// @title Gelato Relay V2 contract/// @notice This contract deals with Gelato 1Balance payments/// @dev This contract must NEVER hold funds!/// @dev Maliciously crafted transaction payloads could wipe out any funds left here// solhint-disable-next-line max-states-countcontractGelatoRelay1BalanceV2isIGelatoRelay1BalanceV2, IGelato1BalanceV2{
usingGelatoCallUtilsforaddress;
/// @notice Relay call + One Balance payment - with sponsor authentication/// @dev This method can be called directly without passing through the diamond/// @dev The validity of the emitted LogUseGelato1BalanceV2 event must be verified off-chain/// @dev Payment is handled with off-chain accounting using Gelato's 1Balance system/// @param _target Relay call target/// @param _data Relay call data/// @param _correlationId Unique task identifier generated by gelato/// Signature is split into `r` and `vs` - See https://eips.ethereum.org/EIPS/eip-2098/// @param _r Checker signature/// @param _vs Checker signaturefunctionsponsoredCallV2(address _target,
bytescalldata _data,
bytes32 _correlationId,
bytes32 _r,
bytes32 _vs
) external{
// These parameters are decoded from calldata
(_correlationId);
(_r);
(_vs);
// INTERACTIONS
_target.revertingContractCall(_data, "GelatoRelay.sponsoredCallV2:");
emit LogUseGelato1BalanceV2();
}
}