-
Notifications
You must be signed in to change notification settings - Fork 27
/
GasSponsorInvoker.sol
36 lines (31 loc) · 1.28 KB
/
GasSponsorInvoker.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import { BaseAuth } from "./BaseAuth.sol";
/// @title Gas Sponsor Invoker
/// @notice Invoker contract using EIP-3074 to sponsor gas for authorized transactions
contract GasSponsorInvoker is BaseAuth {
/// @notice Executes a call authorized by an external account (EOA)
/// @param authority The address of the authorizing external account
/// @param v The recovery byte of the signature
/// @param r Half of the ECDSA signature pair
/// @param s Half of the ECDSA signature pair
/// @param to The target contract address to call
/// @param data The data payload for the call
/// @return success True if the call was successful
function sponsorCall(
address authority,
uint8 v,
bytes32 r,
bytes32 s,
address to,
bytes calldata data,
uint256 value
) external pure returns (bool success) {
bytes32 commit = keccak256(abi.encode(to, data));
// Ensure the transaction is authorized by the signer
require(authSimple(authority, commit, v, r, s), "Authorization failed");
// Execute the call as authorized by the signer
success = authCallSimple(to, data, value, 0);
require(success, "Call execution failed");
}
}