Skip to content

Commit

Permalink
Use hard coded schema-id
Browse files Browse the repository at this point in the history
  • Loading branch information
Builddddder committed Oct 24, 2023
1 parent aab1e1c commit 83254b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 2 additions & 6 deletions contracts/src/examples/modules/SchemaCheckerModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ contract SchemaCheckerModule is AbstractModule {
address /*txSender*/,
uint256 /*value*/
) public view override {
Profile memory issuerProfile;
(issuerProfile.issuer, issuerProfile.schemaId, issuerProfile.issueDate) = abi.decode(
attestationPayload.attestationData,
(address, bytes32, uint64)
);
if (issuerProfile.schemaId != attestationPayload.schemaId) {
if (keccak256(abi.encodePacked(attestationPayload.schemaId)) != keccak256(abi.encode(bytes32("12345678")))) {
revert InvalidSchemaId();
}
abi.decode(attestationPayload.attestationData, (address, bytes32, uint64));
}
}
9 changes: 4 additions & 5 deletions contracts/test/example/SchemaCheckerModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ contract SchemaCheckerModuleTest is Test {
vm.deal(issuer, 1 ether);
}

function test_SchemaCheckerModule_verifySchemaId() public {
function test_SchemaCheckerModule_matchSchemaId() public {
address user = makeAddr("user");
bytes32 schemaId = bytes32(uint256(1234));
uint64 issueDate = 0;
AttestationPayload memory attestationPayload = AttestationPayload(
schemaId,
bytes32("12345678"),
0,
abi.encode(user),
abi.encode(issuer, schemaId, issueDate)
abi.encode(issuer, "112334", issueDate)
);

schemaCheckerModule.run(attestationPayload, bytes("0000"), user, 0);
Expand All @@ -47,7 +46,7 @@ contract SchemaCheckerModuleTest is Test {
schemaCheckerModule.run(attestationPayload, bytes("0000"), user, 0);
}

function test_EcRecoverModule_supportsInterface() public {
function test_SchemaCheckerModule_supportsInterface() public {
bool isAbstractModuleSupported = schemaCheckerModule.supportsInterface(type(AbstractModule).interfaceId);
assertEq(isAbstractModuleSupported, true);
}
Expand Down

0 comments on commit 83254b4

Please sign in to comment.