Skip to content

Commit

Permalink
Merge pull request #79 from rhinestonewtf/feature/add-schema-resolver
Browse files Browse the repository at this point in the history
feat: add schema and resolver
  • Loading branch information
kopy-kat authored Jan 31, 2025
2 parents b264793 + 643a1df commit e0a6303
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 51 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/artifacts.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ jobs:
with:
match-path: "test/**/*.sol"
codecov-slug: zeroknots/registry

release-artifacts:
needs: ["build"]
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-release.yaml@main"
strategy:
matrix:
contract-name:
[
"Registry",
"RSResolver",
"RSSchemaValidator",
"TransparentUpgradeableProxy",
"MockCombination",
]
with:
contract-name: ${{ matrix.contract-name }}
store-artifacts: true
16 changes: 16 additions & 0 deletions build-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash


# Check if a contract name is provided
if [ $# -eq 0 ]; then
echo "Please provide a contract name as an argument."
echo "Usage: $0 <ContractName>"
exit 1
fi

CONTRACT_NAME=$1

mkdir -p ./artifacts/$CONTRACT_NAME
forge build $CONTRACT_NAME
cp ./out/$CONTRACT_NAME.sol/* ./artifacts/$CONTRACT_NAME/.
forge verify-contract --show-standard-json-input $(cast address-zero) $CONTRACT_NAME > ./artifacts/$CONTRACT_NAME/verify.json
36 changes: 0 additions & 36 deletions script/DeployRegistry.s.sol

This file was deleted.

4 changes: 4 additions & 0 deletions src/external/Proxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

Check warning on line 4 in src/external/Proxy.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

imported name TransparentUpgradeableProxy is not used
40 changes: 40 additions & 0 deletions src/external/RSResolver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { IExternalResolver } from "src/external/IExternalResolver.sol";
import "src/DataTypes.sol";

Check warning on line 5 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

global import of path src/DataTypes.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

contract RSResolver is IExternalResolver {
function resolveAttestation(AttestationRecord calldata attestation) public payable returns (bool attestationIsValid) {

Check warning on line 8 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "attestation" is unused
return true;
}

function resolveAttestation(AttestationRecord[] calldata attestation) external payable returns (bool) {

Check warning on line 12 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "attestation" is unused
return true;
}

function resolveRevocation(AttestationRecord calldata attestation) external payable returns (bool) {

Check warning on line 16 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "attestation" is unused
return true;
}

function resolveRevocation(AttestationRecord[] calldata attestation) external payable returns (bool) {

Check warning on line 20 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "attestation" is unused
return true;
}

function resolveModuleRegistration(
address sender,

Check warning on line 25 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "sender" is unused
address moduleAddress,

Check warning on line 26 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "moduleAddress" is unused
ModuleRecord calldata record,

Check warning on line 27 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "record" is unused
bytes calldata resolverContext

Check warning on line 28 in src/external/RSResolver.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Variable "resolverContext" is unused
)
external
payable
returns (bool)
{
return true;
}

function supportsInterface(bytes4 interfaceID) external pure override returns (bool) {
return (interfaceID == type(IExternalResolver).interfaceId);
}
}
26 changes: 26 additions & 0 deletions src/external/RSSchemaValidator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { IExternalSchemaValidator } from "src/external/IExternalSchemaValidator.sol";
import "src/DataTypes.sol";

contract RSSchemaValidator is IExternalSchemaValidator {
error InvalidAttestationData();

function getSchema() external returns (string memory schema) {
return
"(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))";

Check failure on line 12 in src/external/RSSchemaValidator.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Line length must be no more than 140 but current length is 593
}

function validateSchema(AttestationRecord calldata attestation) public override returns (bool valid) {
return true;
}

function validateSchema(AttestationRecord[] calldata attestations) external override returns (bool) {
return true;
}

function supportsInterface(bytes4 interfaceID) external pure override returns (bool) {
return (interfaceID == type(IExternalSchemaValidator).interfaceId);
}
}
2 changes: 1 addition & 1 deletion test/Factory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.0;

import "./Base.t.sol";
import "../script/Create2Factory.sol";
import "./mocks/Create2Factory.sol";

contract MockModuleFoo {
uint256 public value;
Expand Down
File renamed without changes.
87 changes: 87 additions & 0 deletions test/mocks/MockCombination.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import { IExternalResolver } from "src/external/IExternalResolver.sol";
import { IExternalSchemaValidator } from "src/external/IExternalSchemaValidator.sol";
import { IRegistry } from "src/IRegistry.sol";
import "src/DataTypes.sol";

contract MockCombination is IExternalResolver, IExternalSchemaValidator {
bool immutable returnVal;

event AttestationCalled();
event RevokeCalled();
event ModuleCalled();

constructor(bool ret) {
returnVal = ret;
}

/*//////////////////////////////////////////////////////////////////////////
RESOLVER
//////////////////////////////////////////////////////////////////////////*/

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) {
emit AttestationCalled();
return returnVal;
}

function resolveAttestation(AttestationRecord[] calldata attestation) external payable override returns (bool) {
emit AttestationCalled();
return returnVal;
}

function resolveRevocation(AttestationRecord calldata attestation) external payable override returns (bool) {
emit RevokeCalled();
return returnVal;
}

function resolveRevocation(AttestationRecord[] calldata attestation) external payable override returns (bool) {
emit RevokeCalled();
return returnVal;
}

function resolveModuleRegistration(
address sender,
address moduleRecord,
ModuleRecord calldata record,
bytes calldata resolverContext
)
external
payable
override
returns (bool)
{
emit ModuleCalled();
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);
}

function revoke(IRegistry registry, RevocationRequest[] calldata requests) external payable returns (bool) {
require(msg.sender == address(0xD1dcdD8e6Fe04c338aC3f76f7D7105bEcab74F77), "Only Rhinestone team can revoke");
registry.revoke(requests);
}
}

0 comments on commit e0a6303

Please sign in to comment.