编译器
0.8.20+commit.a1b79de6
文件 1 的 5:GelatoBytes.sol
pragma solidity 0.8.20;
library GelatoBytes {
function calldataSliceSelector(
bytes calldata _bytes
) internal pure returns (bytes4 selector) {
selector =
_bytes[0] |
(bytes4(_bytes[1]) >> 8) |
(bytes4(_bytes[2]) >> 16) |
(bytes4(_bytes[3]) >> 24);
}
function memorySliceSelector(
bytes memory _bytes
) internal pure returns (bytes4 selector) {
selector =
_bytes[0] |
(bytes4(_bytes[1]) >> 8) |
(bytes4(_bytes[2]) >> 16) |
(bytes4(_bytes[3]) >> 24);
}
function revertWithError(
bytes memory _bytes,
string memory _tracingInfo
) internal pure {
if (_bytes.length % 32 == 4) {
bytes4 selector;
assembly {
selector := mload(add(0x20, _bytes))
}
if (selector == 0x08c379a0) {
assembly {
_bytes := add(_bytes, 68)
}
revert(string(abi.encodePacked(_tracingInfo, string(_bytes))));
} else {
revert(
string(abi.encodePacked(_tracingInfo, "NoErrorSelector"))
);
}
} else {
revert(
string(abi.encodePacked(_tracingInfo, "UnexpectedReturndata"))
);
}
}
function returnError(
bytes memory _bytes,
string memory _tracingInfo
) internal pure returns (string memory) {
if (_bytes.length % 32 == 4) {
bytes4 selector;
assembly {
selector := mload(add(0x20, _bytes))
}
if (selector == 0x08c379a0) {
assembly {
_bytes := add(_bytes, 68)
}
return string(abi.encodePacked(_tracingInfo, string(_bytes)));
} else {
return
string(abi.encodePacked(_tracingInfo, "NoErrorSelector"));
}
} else {
return
string(abi.encodePacked(_tracingInfo, "UnexpectedReturndata"));
}
}
}
文件 2 的 5:GelatoCallUtils.sol
pragma solidity 0.8.20;
import {GelatoBytes} from "./GelatoBytes.sol";
library GelatoCallUtils {
using GelatoBytes for bytes;
function revertingContractCall(
address _contract,
bytes memory _data,
string memory _errorMsg
) internal returns (bytes memory returndata) {
bool success;
(success, returndata) = _contract.call(_data);
if (success) {
if (returndata.length == 0) {
require(
isContract(_contract),
string(abi.encodePacked(_errorMsg, "Call to non contract"))
);
}
} else {
returndata.revertWithError(_errorMsg);
}
}
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
}
文件 3 的 5:GelatoRelay1BalanceV2.sol
pragma solidity 0.8.20;
import {IGelatoRelay1BalanceV2} from "./interfaces/IGelatoRelay1BalanceV2.sol";
import {IGelato1BalanceV2} from "./interfaces/IGelato1BalanceV2.sol";
import {GelatoCallUtils} from "./lib/GelatoCallUtils.sol";
contract GelatoRelay1BalanceV2 is IGelatoRelay1BalanceV2, IGelato1BalanceV2 {
using GelatoCallUtils for address;
function sponsoredCallV2(
address _target,
bytes calldata _data,
bytes32 _correlationId,
bytes32 _r,
bytes32 _vs
) external {
(_correlationId);
(_r);
(_vs);
_target.revertingContractCall(_data, "GelatoRelay.sponsoredCallV2:");
emit LogUseGelato1BalanceV2();
}
}
文件 4 的 5:IGelato1BalanceV2.sol
pragma solidity 0.8.20;
interface IGelato1BalanceV2 {
event LogUseGelato1BalanceV2();
}
文件 5 的 5:IGelatoRelay1BalanceV2.sol
pragma solidity 0.8.20;
interface IGelatoRelay1BalanceV2 {
function sponsoredCallV2(
address _target,
bytes calldata _data,
bytes32 _correlationId,
bytes32 _r,
bytes32 _vs
) external;
}
{
"compilationTarget": {
"contracts/GelatoRelay1BalanceV2.sol": "GelatoRelay1BalanceV2"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 999999
},
"remappings": []
}
[{"anonymous":false,"inputs":[],"name":"LogUseGelato1BalanceV2","type":"event"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"bytes32","name":"_correlationId","type":"bytes32"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_vs","type":"bytes32"}],"name":"sponsoredCallV2","outputs":[],"stateMutability":"nonpayable","type":"function"}]