mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
27 lines
729 B
Solidity
27 lines
729 B
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
abstract contract ContextMixin {
|
|
function msgSender()
|
|
internal
|
|
view
|
|
returns (address payable sender)
|
|
{
|
|
if (msg.sender == address(this)) {
|
|
bytes memory array = msg.data;
|
|
uint256 index = msg.data.length;
|
|
assembly {
|
|
// Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
|
|
sender := and(
|
|
mload(add(array, index)),
|
|
0xffffffffffffffffffffffffffffffffffffffff
|
|
)
|
|
}
|
|
} else {
|
|
sender = payable(msg.sender);
|
|
}
|
|
return sender;
|
|
}
|
|
}
|