Skip to content

Commit 5cbfd14

Browse files
committed
feat: add mock combination component
1 parent 145c7b7 commit 5cbfd14

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

test/mocks/MockCombination.sol

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
import "src/external/IExternalResolver.sol";
5+
import "src/external/IExternalSchemaValidator.sol";
6+
import { IRegistry, SchemaUID, AttestationRequest } from "src/IRegistry.sol";
7+
8+
contract MockCombination is IExternalResolver, IExternalSchemaValidator {
9+
bool immutable returnVal;
10+
11+
bool public onAttestCalled;
12+
bool public onRevokeCalled;
13+
bool public onModuleCalled;
14+
15+
constructor(bool ret) {
16+
returnVal = ret;
17+
}
18+
19+
/*//////////////////////////////////////////////////////////////////////////
20+
RESOLVER
21+
//////////////////////////////////////////////////////////////////////////*/
22+
23+
function reset() public {
24+
onAttestCalled = false;
25+
onRevokeCalled = false;
26+
onModuleCalled = false;
27+
}
28+
29+
function supportsInterface(bytes4 interfaceId) public pure override returns (bool) {
30+
if (interfaceId == type(IExternalResolver).interfaceId || interfaceId == type(IExternalSchemaValidator).interfaceId) return true;
31+
}
32+
33+
function resolveAttestation(AttestationRecord calldata attestation) external payable override returns (bool) {
34+
onAttestCalled = true;
35+
return returnVal;
36+
}
37+
38+
function resolveAttestation(AttestationRecord[] calldata attestation) external payable override returns (bool) {
39+
onAttestCalled = true;
40+
return returnVal;
41+
}
42+
43+
function resolveRevocation(AttestationRecord calldata attestation) external payable override returns (bool) {
44+
revert();
45+
onRevokeCalled = true;
46+
return returnVal;
47+
}
48+
49+
function resolveRevocation(AttestationRecord[] calldata attestation) external payable override returns (bool) {
50+
revert();
51+
onRevokeCalled = true;
52+
return returnVal;
53+
}
54+
55+
function resolveModuleRegistration(
56+
address sender,
57+
address moduleRecord,
58+
ModuleRecord calldata record,
59+
bytes calldata resolverContext
60+
)
61+
external
62+
payable
63+
override
64+
returns (bool)
65+
{
66+
onModuleCalled = true;
67+
return returnVal;
68+
}
69+
70+
/*//////////////////////////////////////////////////////////////////////////
71+
SCHEMA VALIDATOR
72+
//////////////////////////////////////////////////////////////////////////*/
73+
74+
function validateSchema(AttestationRecord calldata attestation) external view override returns (bool) {
75+
return returnVal;
76+
}
77+
78+
function validateSchema(AttestationRecord[] calldata attestations) external view override returns (bool) {
79+
return returnVal;
80+
}
81+
82+
/*//////////////////////////////////////////////////////////////////////////
83+
MOCK ATTESTER
84+
//////////////////////////////////////////////////////////////////////////*/
85+
86+
function attest(IRegistry registry, SchemaUID schemaUID, AttestationRequest calldata request) external payable returns (bool) {
87+
registry.attest(schemaUID, request);
88+
}
89+
}

0 commit comments

Comments
 (0)