-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eth Gateway: An upgradeable version of GatedERC2771
- Loading branch information
1 parent
860c541
commit 33ec5cd
Showing
2 changed files
with
32 additions
and
37 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
ethereum/smart-contract/contracts/GatedERC2771Upgradeable.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,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.9; | ||
|
||
import {IGatewayTokenVerifier} from "./interfaces/IGatewayTokenVerifier.sol"; | ||
import {MultiERC2771Context} from "./MultiERC2771Context.sol"; | ||
|
||
abstract contract GatedERC2771Upgradeable is MultiERC2771Context { | ||
address private _gatewayTokenContract; | ||
uint256 private _gatekeeperNetwork; | ||
|
||
/// The gateway token is not valid. | ||
error IsGated__InvalidGatewayToken(address gatewayToken); | ||
|
||
modifier gated() { | ||
IGatewayTokenVerifier verifier = IGatewayTokenVerifier(_gatewayTokenContract); | ||
if (!verifier.verifyToken(_msgSender(), _gatekeeperNetwork)) { | ||
revert IsGated__InvalidGatewayToken(_gatewayTokenContract); | ||
} | ||
_; | ||
} | ||
|
||
// solhint-disable-next-line func-name-mixedcase | ||
function __GatedERC2771Upgradeable_init( | ||
address gatewayTokenContract, | ||
uint256 gatekeeperNetwork, | ||
address[] calldata trustedForwarders | ||
) internal initializer { | ||
_gatewayTokenContract = gatewayTokenContract; | ||
_gatekeeperNetwork = gatekeeperNetwork; | ||
__MultiERC2771Context_init(trustedForwarders); | ||
} | ||
} |
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