From fd00e0b10db8c00524106dc24847bf6965ed8633 Mon Sep 17 00:00:00 2001 From: Alain Nicolas Date: Tue, 19 Sep 2023 11:12:53 +0200 Subject: [PATCH] feat: As an Issuer, I want the context of a Schema to be optional (#213) --- src/SchemaRegistry.sol | 4 ---- test/SchemaRegistry.t.sol | 11 ++--------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/SchemaRegistry.sol b/src/SchemaRegistry.sol index 89ee16c5..1ad8c5c0 100644 --- a/src/SchemaRegistry.sol +++ b/src/SchemaRegistry.sol @@ -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(); @@ -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); @@ -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; } diff --git a/test/SchemaRegistry.t.sol b/test/SchemaRegistry.t.sol index ac7a48fa..d85294e1 100644 --- a/test/SchemaRegistry.t.sol +++ b/test/SchemaRegistry.t.sol @@ -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); @@ -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(); }