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.
Merge pull request #79 from rhinestonewtf/feature/add-schema-resolver
feat: add schema and resolver
- Loading branch information
Showing
10 changed files
with
191 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
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,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import { IExternalResolver } from "src/external/IExternalResolver.sol"; | ||
import "src/DataTypes.sol"; | ||
|
||
contract RSResolver is IExternalResolver { | ||
function resolveAttestation(AttestationRecord calldata attestation) public payable returns (bool attestationIsValid) { | ||
return true; | ||
} | ||
|
||
function resolveAttestation(AttestationRecord[] calldata attestation) external payable returns (bool) { | ||
return true; | ||
} | ||
|
||
function resolveRevocation(AttestationRecord calldata attestation) external payable returns (bool) { | ||
return true; | ||
} | ||
|
||
function resolveRevocation(AttestationRecord[] calldata attestation) external payable returns (bool) { | ||
return true; | ||
} | ||
|
||
function resolveModuleRegistration( | ||
address sender, | ||
address moduleAddress, | ||
ModuleRecord calldata record, | ||
bytes calldata resolverContext | ||
) | ||
external | ||
payable | ||
returns (bool) | ||
{ | ||
return true; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceID) external pure override returns (bool) { | ||
return (interfaceID == type(IExternalResolver).interfaceId); | ||
} | ||
} |
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,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))"; | ||
} | ||
|
||
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); | ||
} | ||
} |
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,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); | ||
} | ||
} |