@@ -6,9 +6,10 @@ import {IGelato1Balance} from "./interfaces/IGelato1Balance.sol";
66import {GelatoRelayBase} from "./abstract/GelatoRelayBase.sol " ;
77import {GelatoCallUtils} from "./lib/GelatoCallUtils.sol " ;
88import {GelatoTokenUtils} from "./lib/GelatoTokenUtils.sol " ;
9+ import {SponsoredCall} from "./types/CallTypes.sol " ;
910import {
10- _encodeGelatoRelayContext ,
11- _encodeFeeCollector
11+ _encodeFeeCollector ,
12+ _encodeRelayContext
1213} from "@gelatonetwork/relay-context/contracts/functions/GelatoRelayUtils.sol " ;
1314import {
1415 __getFeeCollector
@@ -18,9 +19,8 @@ import {
1819 _getFeeTokenRelayContext,
1920 _getFeeRelayContext
2021} from "@gelatonetwork/relay-context/contracts/GelatoRelayContext.sol " ;
21- import {_eip2771Context} from "./functions/ContextUtils.sol " ;
22- import {SponsoredCall, SponsoredUserAuthCall} from "./types/CallTypes.sol " ;
23- import {IGelato} from "./interfaces/IGelato.sol " ;
22+ // backwards compatible encoding for msg.sender support instead of feeCollector
23+ import {_deprecatedRelayContext} from "./functions/DeprecatedUtils.sol " ;
2424
2525/// @title Gelato Relay contract
2626/// @notice This contract deals with synchronous payments and Gelato 1Balance payments
@@ -34,7 +34,7 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
3434 //solhint-disable-next-line const-name-snakecase
3535 string public constant name = "GelatoRelay " ;
3636 //solhint-disable-next-line const-name-snakecase
37- string public constant version = "1 " ;
37+ string public constant version = "2 " ;
3838
3939 // solhint-disable-next-line no-empty-blocks
4040 constructor (address _gelato ) GelatoRelayBase (_gelato) {}
@@ -50,7 +50,7 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
5050 uint256 preBalance = _feeToken.getBalance (address (this ));
5151
5252 _target.revertingContractCall (
53- _encodeGelatoRelayContext (_data, msg .sender , _feeToken, _fee),
53+ _deprecatedRelayContext (_data, msg .sender , _feeToken, _fee),
5454 "GelatoRelay.callWithSyncFee: "
5555 );
5656
@@ -68,25 +68,25 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
6868 /// @dev This is the most straightforward use case, and `transfer` handles token payments.
6969 /// @param _target Target smart contract
7070 /// @param _data Payload for call on _target
71- /// @param _relayContext true: all relay context encoding, false: only feeCollector encoding
71+ /// @param _isRelayContext true: all relay context encoding, false: only feeCollector encoding
7272 /// @param _correlationId Unique task identifier generated by gelato
7373 function callWithSyncFeeV2 (
7474 address _target ,
7575 bytes calldata _data ,
76- bool _relayContext ,
76+ bool _isRelayContext ,
7777 bytes32 _correlationId
7878 ) external onlyGelato {
7979 address feeToken;
8080 uint256 preBalance;
8181
82- if (_relayContext ) {
82+ if (_isRelayContext ) {
8383 feeToken = _getFeeTokenRelayContext ();
8484 preBalance = feeToken.getBalance (address (this ));
8585 }
8686
87- _relayContext
87+ _isRelayContext
8888 ? _target.revertingContractCall (
89- _encodeGelatoRelayContext (
89+ _encodeRelayContext (
9090 _data,
9191 _getFeeCollectorRelayContext (),
9292 feeToken,
@@ -99,7 +99,7 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
9999 "GelatoRelay.callWithSyncFeeV2: "
100100 );
101101
102- if (_relayContext ) {
102+ if (_isRelayContext ) {
103103 uint256 fee = feeToken.getBalance (address (this )) - preBalance;
104104 if (fee != 0 ) feeToken.transfer (msg .sender , fee);
105105 }
@@ -145,71 +145,6 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
145145 );
146146 }
147147
148- /// @notice Relay call + One Balance payment - with BOTH sponsor and user authentication
149- /// @notice Both sponsor and user signature allows for payment via sponsor's 1Balance balance
150- /// @dev Payment is handled with off-chain accounting using Gelato's 1Balance system
151- /// @dev The userNonce abstraction does not support multiple calls (call concurrency)
152- /// @dev Apps that need concurrent user calls will need to implement multi-calling
153- /// @dev on their end via encoding into _call.data.
154- /// @param _call Relay call data packed into SponsoredUserAuthCall struct
155- /// @param _userSignature EIP-712 compliant signature from _call.user
156- /// @param _nativeToFeeTokenXRateNumerator Exchange rate numerator
157- /// @param _nativeToFeeTokenXRateDenominator Exchange rate denominator
158- /// @param _correlationId Unique task identifier generated by gelato
159- // solhint-disable-next-line function-max-lines
160- function sponsoredUserAuthCall (
161- SponsoredUserAuthCall calldata _call ,
162- address _sponsor ,
163- address _feeToken ,
164- uint256 _oneBalanceChainId ,
165- bytes calldata _userSignature ,
166- uint256 _nativeToFeeTokenXRateNumerator ,
167- uint256 _nativeToFeeTokenXRateDenominator ,
168- bytes32 _correlationId
169- ) external onlyGelato {
170- // CHECKS
171- _requireChainId (_call.chainId, "GelatoRelay.sponsoredUserAuthCall: " );
172-
173- uint256 storedUserNonce = userNonce[_call.user];
174-
175- // For the user, we enforce nonce ordering
176- _requireUserBasics (
177- _call.userNonce,
178- storedUserNonce,
179- _call.userDeadline,
180- "GelatoRelay.sponsoredUserAuthCall: "
181- );
182-
183- bytes32 domainSeparator = _getDomainSeparator ();
184-
185- // Verify user's signature
186- _requireSponsoredUserAuthCallSignature (
187- domainSeparator,
188- _call,
189- _userSignature,
190- _call.user
191- );
192-
193- // EFFECTS
194- userNonce[_call.user] = storedUserNonce + 1 ;
195-
196- // INTERACTIONS
197- _call.target.revertingContractCall (
198- _eip2771Context (_call.data, _call.user),
199- "GelatoRelay.sponsoredUserAuthCall: "
200- );
201-
202- emit LogUseGelato1Balance (
203- _sponsor,
204- _call.target,
205- _feeToken,
206- _oneBalanceChainId,
207- _nativeToFeeTokenXRateNumerator,
208- _nativeToFeeTokenXRateDenominator,
209- _correlationId
210- );
211- }
212-
213148 //solhint-disable-next-line func-name-mixedcase
214149 function DOMAIN_SEPARATOR () external view returns (bytes32 ) {
215150 return _getDomainSeparator ();
0 commit comments