// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.20;
contract MultiRewardCall {
struct Call {
address target;
bytes callData;
}
/// @notice Claim multiple rewards
/// @param calls An array of Call structs
/// @return blockNumber The block number where the calls were executed
/// @return returnData An array of bytes containing the responses
function claim(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData) {
blockNumber = block.number;
uint256 length = calls.length;
returnData = new bytes[](length);
Call calldata call;
for (uint256 i = 0; i < length;) {
bool success;
call = calls[i];
(success, returnData[i]) = call.target.call(call.callData);
require(success, "MultiRewardCall: call failed");
unchecked {
++i;
}
}
}
}
{
"compilationTarget": {
"contracts/MultiRewardCall.sol": "MultiRewardCall"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct MultiRewardCall.Call[]","name":"calls","type":"tuple[]"}],"name":"claim","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes[]","name":"returnData","type":"bytes[]"}],"stateMutability":"payable","type":"function"}]