generated from EthSign/forge-hardhat-template-old
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
File renamed without changes.
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,80 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.26; | ||
|
||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; | ||
import { ISPHook } from "@ethsign/sign-protocol-evm/src/interfaces/ISPHook.sol"; | ||
|
||
// @dev This contract manages the whitelist. We are separating the whitelist logic from the hook to make things easier | ||
// to read. | ||
contract WhitelistMananger is Ownable { | ||
mapping(address attester => bool allowed) public whitelist; | ||
|
||
error UnauthorizedAttester(); | ||
|
||
constructor() Ownable(_msgSender()) { } | ||
|
||
function setWhitelist(address attester, bool allowed) external onlyOwner { | ||
whitelist[attester] = allowed; | ||
} | ||
|
||
function _checkAttesterWhitelistStatus(address attester) internal view { | ||
// solhint-disable-next-line custom-errors | ||
require(whitelist[attester], UnauthorizedAttester()); | ||
} | ||
} | ||
|
||
// @dev This contract implements the actual schema hook. | ||
contract WhitelistHook is ISPHook, WhitelistMananger { | ||
function didReceiveAttestation( | ||
address attester, | ||
uint64, // schemaId | ||
uint64, // attestationId | ||
bytes calldata // extraData | ||
) | ||
external | ||
payable | ||
{ | ||
_checkAttesterWhitelistStatus(attester); | ||
} | ||
|
||
function didReceiveAttestation( | ||
address attester, | ||
uint64, // schemaId | ||
uint64, // attestationId | ||
IERC20, // resolverFeeERC20Token | ||
uint256, // resolverFeeERC20Amount | ||
bytes calldata // extraData | ||
) | ||
external | ||
view | ||
{ | ||
_checkAttesterWhitelistStatus(attester); | ||
} | ||
|
||
function didReceiveRevocation( | ||
address attester, | ||
uint64, // schemaId | ||
uint64, // attestationId | ||
bytes calldata // extraData | ||
) | ||
external | ||
payable | ||
{ | ||
_checkAttesterWhitelistStatus(attester); | ||
} | ||
|
||
function didReceiveRevocation( | ||
address attester, | ||
uint64, // schemaId | ||
uint64, // attestationId | ||
IERC20, // resolverFeeERC20Token | ||
uint256, // resolverFeeERC20Amount | ||
bytes calldata // extraData | ||
) | ||
external | ||
view | ||
{ | ||
_checkAttesterWhitelistStatus(attester); | ||
} | ||
} |