@@ -7,49 +7,7 @@ import { _IContext } from './_IContext.sol';
7
7
* @title Utility contract for supporting alternative authorization schemes
8
8
*/
9
9
abstract contract _Context is _IContext {
10
- /*
11
- * @notice Returns the intended sender of a message. Either msg.sender or the address of the authorizing signer.
12
- * Enables MetaTransactions, since the sender doesn't need to be the tx.origin or even the msg.sender.
13
- * @returns address - The account whose authority is being acted on.
14
- * and the end-user for GSN relayed calls (where msg.sender is actually `RelayHub`).
15
- *
16
- * IMPORTANT: Contracts derived from {GSNRecipient} should never use `msg.sender`, and use {_msgSender} instead.
17
- */
18
- function _msgSender () internal view virtual returns (address sender ) {
19
- if (msg .sender == address (this )) {
20
- return _getRelayedCallSender ();
21
- } else {
22
- sender = msg .sender ;
23
- }
24
- return sender;
25
- }
26
-
27
- function _getRelayedCallSender ()
28
- private
29
- pure
30
- returns (address payable result )
31
- {
32
- // We need to read 20 bytes (an address) located at array index msg.data.length - 20. In memory, the array
33
- // is prefixed with a 32-byte length value, so we first add 32 to get the memory read index. However, doing
34
- // so would leave the address in the upper 20 bytes of the 32-byte word, which is inconvenient and would
35
- // require bit shifting. We therefore subtract 12 from the read index so the address lands on the lower 20
36
- // bytes. This can always be done due to the 32-byte prefix.
37
-
38
- // The final memory read index is msg.data.length - 20 + 32 - 12 = msg.data.length. Using inline assembly is the
39
- // easiest/most-efficient way to perform this operation.
40
-
41
- // These fields are not accessible from assembly
42
- bytes memory array = msg .data ;
43
- uint256 index = msg .data .length ;
44
-
45
- // solhint-disable-next-line no-inline-assembly
46
- assembly {
47
- // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
48
- result := and (
49
- mload (add (array, index)),
50
- 0xffffffffffffffffffffffffffffffffffffffff
51
- )
52
- }
53
- return result;
10
+ function _msgSender () internal view virtual returns (address msgSender ) {
11
+ msgSender = msg .sender ;
54
12
}
55
13
}
0 commit comments