Skip to content

Commit e0a6303

Browse files
authored
Merge pull request #79 from rhinestonewtf/feature/add-schema-resolver
feat: add schema and resolver
2 parents b264793 + 643a1df commit e0a6303

10 files changed

+191
-51
lines changed

.github/workflows/artifacts.yaml

-14
This file was deleted.

.github/workflows/ci.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,20 @@ jobs:
2727
with:
2828
match-path: "test/**/*.sol"
2929
codecov-slug: zeroknots/registry
30+
31+
release-artifacts:
32+
needs: ["build"]
33+
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-release.yaml@main"
34+
strategy:
35+
matrix:
36+
contract-name:
37+
[
38+
"Registry",
39+
"RSResolver",
40+
"RSSchemaValidator",
41+
"TransparentUpgradeableProxy",
42+
"MockCombination",
43+
]
44+
with:
45+
contract-name: ${{ matrix.contract-name }}
46+
store-artifacts: true

build-artifacts.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
4+
# Check if a contract name is provided
5+
if [ $# -eq 0 ]; then
6+
echo "Please provide a contract name as an argument."
7+
echo "Usage: $0 <ContractName>"
8+
exit 1
9+
fi
10+
11+
CONTRACT_NAME=$1
12+
13+
mkdir -p ./artifacts/$CONTRACT_NAME
14+
forge build $CONTRACT_NAME
15+
cp ./out/$CONTRACT_NAME.sol/* ./artifacts/$CONTRACT_NAME/.
16+
forge verify-contract --show-standard-json-input $(cast address-zero) $CONTRACT_NAME > ./artifacts/$CONTRACT_NAME/verify.json

script/DeployRegistry.s.sol

-36
This file was deleted.

src/external/Proxy.sol

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.24;
3+
4+
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

src/external/RSResolver.sol

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.24;
3+
4+
import { IExternalResolver } from "src/external/IExternalResolver.sol";
5+
import "src/DataTypes.sol";
6+
7+
contract RSResolver is IExternalResolver {
8+
function resolveAttestation(AttestationRecord calldata attestation) public payable returns (bool attestationIsValid) {
9+
return true;
10+
}
11+
12+
function resolveAttestation(AttestationRecord[] calldata attestation) external payable returns (bool) {
13+
return true;
14+
}
15+
16+
function resolveRevocation(AttestationRecord calldata attestation) external payable returns (bool) {
17+
return true;
18+
}
19+
20+
function resolveRevocation(AttestationRecord[] calldata attestation) external payable returns (bool) {
21+
return true;
22+
}
23+
24+
function resolveModuleRegistration(
25+
address sender,
26+
address moduleAddress,
27+
ModuleRecord calldata record,
28+
bytes calldata resolverContext
29+
)
30+
external
31+
payable
32+
returns (bool)
33+
{
34+
return true;
35+
}
36+
37+
function supportsInterface(bytes4 interfaceID) external pure override returns (bool) {
38+
return (interfaceID == type(IExternalResolver).interfaceId);
39+
}
40+
}

src/external/RSSchemaValidator.sol

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.24;
3+
4+
import { IExternalSchemaValidator } from "src/external/IExternalSchemaValidator.sol";
5+
import "src/DataTypes.sol";
6+
7+
contract RSSchemaValidator is IExternalSchemaValidator {
8+
error InvalidAttestationData();
9+
10+
function getSchema() external returns (string memory schema) {
11+
return
12+
"(enum ERC7579ModuleType (None,Validator,Executor,Fallback,Hook),struct ModuleTypeAttributes (ERC7579ModuleType moduleType,bytes encodedAttributes),struct ModuleAttributes (address moduleAddress,bytes packedAttributes,ModuleTypeAttributes[] typeAttributes,bytes packedExternalDependency),enum SignatureType (None,SECP256K1,ERC1271),struct Auditor (string name,string uri,string[] authors),struct Signature (SignatureType sigType,address signer,bytes signatureData,bytes32 hash),struct AuditSummary (string title,Auditor auditor,ModuleAttributes moduleAttributes,Signature signature))";
13+
}
14+
15+
function validateSchema(AttestationRecord calldata attestation) public override returns (bool valid) {
16+
return true;
17+
}
18+
19+
function validateSchema(AttestationRecord[] calldata attestations) external override returns (bool) {
20+
return true;
21+
}
22+
23+
function supportsInterface(bytes4 interfaceID) external pure override returns (bool) {
24+
return (interfaceID == type(IExternalSchemaValidator).interfaceId);
25+
}
26+
}

test/Factory.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.0;
33

44
import "./Base.t.sol";
5-
import "../script/Create2Factory.sol";
5+
import "./mocks/Create2Factory.sol";
66

77
contract MockModuleFoo {
88
uint256 public value;
File renamed without changes.

test/mocks/MockCombination.sol

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

0 commit comments

Comments
 (0)