Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: As a user, I want to have an example schema checker module #317

Merged
merged 8 commits into from
Oct 25, 2023
Merged

feat: As a user, I want to have an example schema checker module #317

merged 8 commits into from
Oct 25, 2023

Conversation

Builddddder
Copy link
Contributor

What does this PR do?

Related ticket

Fixes #267

Type of change

  • Chore
  • Bug fix
  • New feature
  • Documentation update

Check list

  • Unit tests for any smart contract change
  • Contracts and functions are documented

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2023

Codecov Report

Merging #317 (0d26591) into dev (10b217f) will increase coverage by 0.11%.
Report is 1 commits behind head on dev.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev     #317      +/-   ##
==========================================
+ Coverage   91.55%   91.66%   +0.11%     
==========================================
  Files          13       14       +1     
  Lines         225      228       +3     
  Branches       53       54       +1     
==========================================
+ Hits          206      209       +3     
  Misses         10       10              
  Partials        9        9              
Files Coverage Δ
...racts/src/examples/modules/SchemaCheckerModule.sol 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Builddddder Builddddder marked this pull request as ready for review October 24, 2023 06:05
@alainncls alainncls changed the title Add SchemaCheckerModule feat: As a user, I want to have an example schema checker module Oct 24, 2023
@orbmis
Copy link
Collaborator

orbmis commented Oct 24, 2023

Would it be better to have a hardcoded schema id here? This module is really an example to make it clear to other developers how you would check a schema, but maybe this could be clearer. What do you think?

What about this:

function run(
    AttestationPayload memory attestationPayload,
    bytes memory /*validationPayload*/,
    address /*txSender*/,
    uint256 /*value*/
  ) public view override {
    if (keccak256(attestationPayload.schemaId) != keccak256(abi.encode("HARDCODED_SCHEMA_ID"))) {
      revert InvalidSchemaId();
    }

    abi.decode(attestationPayload.attestationData, (address, bytes32, uint64));
  }

If the payload adheres to the Schema, this will pass, if not, it will revert. Does that make sense?

@Builddddder
Copy link
Contributor Author

Builddddder commented Oct 24, 2023

I think that's ok for me. New update soon

@Builddddder
Copy link
Contributor Author

@orbmis Updated code, please review again.

@alainncls alainncls enabled auto-merge (squash) October 25, 2023 15:09
@alainncls alainncls merged commit b8b0cb1 into Consensys:dev Oct 25, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[US] As a user, I want to have an example schema checker module
5 participants