generated from zeroknots/femplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mock combination component
- Loading branch information
Showing
1 changed file
with
89 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import "src/external/IExternalResolver.sol"; | ||
import "src/external/IExternalSchemaValidator.sol"; | ||
import { IRegistry, SchemaUID, AttestationRequest } from "src/IRegistry.sol"; | ||
|
||
contract MockCombination is IExternalResolver, IExternalSchemaValidator { | ||
bool immutable returnVal; | ||
|
||
bool public onAttestCalled; | ||
bool public onRevokeCalled; | ||
bool public onModuleCalled; | ||
|
||
constructor(bool ret) { | ||
returnVal = ret; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
RESOLVER | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function reset() public { | ||
onAttestCalled = false; | ||
onRevokeCalled = false; | ||
onModuleCalled = false; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) public pure override returns (bool) { | ||
if (interfaceId == type(IExternalResolver).interfaceId || interfaceId == type(IExternalSchemaValidator).interfaceId) return true; | ||
} | ||
|
||
function resolveAttestation(AttestationRecord calldata attestation) external payable override returns (bool) { | ||
onAttestCalled = true; | ||
return returnVal; | ||
} | ||
|
||
function resolveAttestation(AttestationRecord[] calldata attestation) external payable override returns (bool) { | ||
onAttestCalled = true; | ||
return returnVal; | ||
} | ||
|
||
function resolveRevocation(AttestationRecord calldata attestation) external payable override returns (bool) { | ||
revert(); | ||
onRevokeCalled = true; | ||
return returnVal; | ||
} | ||
|
||
function resolveRevocation(AttestationRecord[] calldata attestation) external payable override returns (bool) { | ||
revert(); | ||
onRevokeCalled = true; | ||
return returnVal; | ||
} | ||
|
||
function resolveModuleRegistration( | ||
address sender, | ||
address moduleRecord, | ||
ModuleRecord calldata record, | ||
bytes calldata resolverContext | ||
) | ||
external | ||
payable | ||
override | ||
returns (bool) | ||
{ | ||
onModuleCalled = true; | ||
return returnVal; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
SCHEMA VALIDATOR | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function validateSchema(AttestationRecord calldata attestation) external view override returns (bool) { | ||
return returnVal; | ||
} | ||
|
||
function validateSchema(AttestationRecord[] calldata attestations) external view override returns (bool) { | ||
return returnVal; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
MOCK ATTESTER | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function attest(IRegistry registry, SchemaUID schemaUID, AttestationRequest calldata request) external payable returns (bool) { | ||
registry.attest(schemaUID, request); | ||
} | ||
} |