-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
properly moved old raffle contrats (first versions)
- Loading branch information
Showing
8 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...s/avatar/contracts/raffleold/common/BaseWithStorage/ERC2771/ERC2771HandlerUpgradeable.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: MIT | ||
// solhint-disable-next-line compiler-version | ||
pragma solidity 0.8.2; | ||
|
||
/// @dev minimal ERC2771 handler to keep bytecode-size down | ||
/// based on: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/metatx/ERC2771Context.sol | ||
/// with an initializer for proxies and a mutable forwarder | ||
/// @dev same as ERC2771Handler.sol but with gap | ||
|
||
contract ERC2771HandlerUpgradeable { | ||
address internal _trustedForwarder; | ||
uint256[49] private __gap; | ||
|
||
function __ERC2771Handler_initialize(address forwarder) internal { | ||
_trustedForwarder = forwarder; | ||
} | ||
|
||
function isTrustedForwarder(address forwarder) public view returns (bool) { | ||
return forwarder == _trustedForwarder; | ||
} | ||
|
||
function getTrustedForwarder() external view returns (address trustedForwarder) { | ||
return _trustedForwarder; | ||
} | ||
|
||
function _msgSender() internal view virtual returns (address sender) { | ||
if (isTrustedForwarder(msg.sender)) { | ||
// The assembly code is more direct than the Solidity version using `abi.decode`. | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
sender := shr(96, calldataload(sub(calldatasize(), 20))) | ||
} | ||
} else { | ||
return msg.sender; | ||
} | ||
} | ||
|
||
function _msgData() internal view virtual returns (bytes calldata) { | ||
if (isTrustedForwarder(msg.sender)) { | ||
return msg.data[:msg.data.length - 20]; | ||
} else { | ||
return msg.data; | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.