@@ -179,17 +179,17 @@ abstract contract GasRelayHelper is GasRelayConstants {
179
179
// default owner, which results in the same UX. The exception is if it's a task.
180
180
if (address (msg .sender ).code.length != 0 && callerType != CallerType.Task) return ;
181
181
182
- bytes32 _packedUnderlyingCaller;
182
+ bytes32 _packedUnderlyingCaller = bytes32 ( uint256 ( uint160 ( address ( msg . sender )))) | _IN_USE_BIT ;
183
183
184
- if (callerType == CallerType.Owner) {
185
- _packedUnderlyingCaller = bytes32 (uint256 (uint160 (address (msg .sender )))) | _IN_USE_BIT;
186
- } else if (callerType == CallerType.SessionKey) {
187
- _packedUnderlyingCaller = bytes32 (uint256 (uint160 (address (msg .sender )))) | _IN_USE_AS_SESSION_KEY_BITS;
188
- } else if (callerType == CallerType.Task) {
189
- _packedUnderlyingCaller = bytes32 (uint256 (uint160 (address (msg .sender )))) | _IN_USE_AS_TASK_BITS;
190
- } else {
191
- revert UnknownMsgSenderType ();
184
+ // NOTE: This treats tasks as session keys!
185
+ if (callerType != CallerType.Owner) {
186
+ _packedUnderlyingCaller |= _IS_SESSION_KEY_BIT;
192
187
}
188
+
189
+ if (callerType == CallerType.Task) {
190
+ _packedUnderlyingCaller |= _IS_TASK_BIT;
191
+ }
192
+
193
193
bytes32 _underlyingCallerTransientSlot = _UNDERLYING_CALLER_NAMESPACE ();
194
194
assembly {
195
195
tstore (_underlyingCallerTransientSlot, _packedUnderlyingCaller)
@@ -305,19 +305,17 @@ abstract contract GasRelayHelper is GasRelayConstants {
305
305
/// @return sessionKey Session key data
306
306
function _loadSessionKey (address sessionKeyAddress ) internal view returns (SessionKey memory sessionKey ) {
307
307
bytes32 _sessionKeyStorageSlot = keccak256 (abi.encodePacked (sessionKeyAddress, _SESSION_KEY_NAMESPACE ()));
308
- address _owner;
309
- uint256 _expiration;
310
- bool _isTask;
308
+ bytes32 _packedSessionKey;
311
309
assembly {
312
- let _packedSessionKey := sload (_sessionKeyStorageSlot)
313
- _owner := and (_packedSessionKey, 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff )
314
- _expiration :=
315
- and (shr (192 , _packedSessionKey), 0x000000000000000000000000000000000000000000000000ffffffffffffffff )
316
- _isTask := gt (and (_packedSessionKey, _IS_TASK_BIT), 0 )
310
+ _packedSessionKey := sload (_sessionKeyStorageSlot)
317
311
}
318
- sessionKey.owner = _owner;
319
- sessionKey.expiration = uint64 (_expiration);
320
- sessionKey.isTask = _isTask;
312
+ sessionKey.owner = address (
313
+ uint160 (uint256 (_packedSessionKey & 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff ))
314
+ );
315
+ sessionKey.expiration = uint64 (
316
+ uint256 (_packedSessionKey >> 192 ) & 0x000000000000000000000000000000000000000000000000ffffffffffffffff
317
+ );
318
+ sessionKey.isTask = _packedSessionKey & _IS_TASK_BIT != 0 ;
321
319
}
322
320
323
321
/// @notice Load session key from owner address
0 commit comments