Skip to content

Commit

Permalink
feat: As an Issuer, I want the context of a Schema to be optional (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls authored Sep 19, 2023
1 parent cbd2142 commit fd00e0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/SchemaRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ contract SchemaRegistry is OwnableUpgradeable {
error SchemaNameMissing();
/// @notice Error thrown when attempting to add a Schema without a string to define it
error SchemaStringMissing();
/// @notice Error thrown when attempting to add a Schema without a context
error SchemaContextMissing();
/// @notice Error thrown when attempting to get a Schema that is not registered
error SchemaNotRegistered();

Expand Down Expand Up @@ -94,7 +92,6 @@ contract SchemaRegistry is OwnableUpgradeable {
) public onlyIssuers(msg.sender) {
if (bytes(name).length == 0) revert SchemaNameMissing();
if (bytes(schemaString).length == 0) revert SchemaStringMissing();
if (bytes(context).length == 0) revert SchemaContextMissing();

bytes32 schemaId = getIdFromSchemaString(schemaString);

Expand All @@ -114,7 +111,6 @@ contract SchemaRegistry is OwnableUpgradeable {
*/
function updateContext(bytes32 schemaId, string memory context) public onlyIssuers(msg.sender) {
if (!isRegistered(schemaId)) revert SchemaNotRegistered();
if (bytes(context).length == 0) revert SchemaContextMissing();
schemas[schemaId].context = context;
}

Expand Down
11 changes: 2 additions & 9 deletions test/SchemaRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ contract SchemaRegistryTest is Test {
schemaRegistry.createSchema(expectedName, expectedDescription, expectedContext, "");
}

function testCannotCreateSchemaWithoutContext() public {
vm.expectRevert(SchemaRegistry.SchemaContextMissing.selector);
vm.prank(user);
schemaRegistry.createSchema(expectedName, expectedDescription, "", expectedString);
}

function testCannotCreateSchemaTwice() public {
vm.startPrank(user);
schemaRegistry.createSchema(expectedName, expectedDescription, expectedContext, expectedString);
Expand Down Expand Up @@ -138,12 +132,11 @@ contract SchemaRegistryTest is Test {
vm.stopPrank();
}

function testCannotUpdateContextWithSchemaContextMissing() public {
function testCanUpdateContextWithEmptySchemaContext() public {
vm.startPrank(user);
schemaRegistry.createSchema(expectedName, expectedDescription, expectedContext, expectedString);

vm.expectRevert(SchemaRegistry.SchemaContextMissing.selector);
schemaRegistry.updateContext(expectedId, "");
assertEq(schemaRegistry.getSchema(expectedId).context, "");
vm.stopPrank();
}

Expand Down

0 comments on commit fd00e0b

Please sign in to comment.