diff --git a/packages/excubiae/contracts/Excubia.sol b/packages/excubiae/contracts/Excubia.sol index 988985e..a91a55a 100644 --- a/packages/excubiae/contracts/Excubia.sol +++ b/packages/excubiae/contracts/Excubia.sol @@ -37,8 +37,8 @@ abstract contract Excubia is IExcubia, Ownable(msg.sender) { } /// @inheritdoc IExcubia - function check(address passerby, bytes calldata data) external view returns (bool) { - return _check(passerby, data); + function check(address passerby, bytes calldata data) external view { + _check(passerby, data); } /// @notice Internal function to enforce the custom gate passing logic. @@ -46,7 +46,7 @@ abstract contract Excubia is IExcubia, Ownable(msg.sender) { /// @param passerby The address of the entity attempting to pass the gate. /// @param data Additional data required for the check (e.g., encoded token identifier). function _pass(address passerby, bytes calldata data) internal virtual { - if (!_check(passerby, data)) revert AccessDenied(); + _check(passerby, data); emit GatePassed(passerby, gate); } @@ -55,5 +55,5 @@ abstract contract Excubia is IExcubia, Ownable(msg.sender) { /// @dev Custom logic to determine if the passerby can pass the gate. /// @param passerby The address of the entity attempting to pass the gate. /// @param data Additional data that may be required for the check. - function _check(address passerby, bytes calldata data) internal view virtual returns (bool) {} + function _check(address passerby, bytes calldata data) internal view virtual {} } diff --git a/packages/excubiae/contracts/IExcubia.sol b/packages/excubiae/contracts/IExcubia.sol index 76c58c1..86a4a80 100644 --- a/packages/excubiae/contracts/IExcubia.sol +++ b/packages/excubiae/contracts/IExcubia.sol @@ -25,9 +25,6 @@ interface IExcubia { /// @notice Error thrown when the gate address has been already set. error GateAlreadySet(); - /// @notice Error thrown when access is denied by the excubia. - error AccessDenied(); - /// @notice Error thrown when the passerby has already passed the gate. error AlreadyPassed(); @@ -45,6 +42,5 @@ interface IExcubia { /// @dev Defines the custom gate protection logic. /// @param passerby The address of the entity attempting to pass the gate. /// @param data Additional data that may be required for the check. - /// @return True if the passerby passes the check, false otherwise. - function check(address passerby, bytes calldata data) external view returns (bool); + function check(address passerby, bytes calldata data) external view; } diff --git a/packages/excubiae/contracts/extensions/EASExcubia.sol b/packages/excubiae/contracts/extensions/EASExcubia.sol index 0b5e989..afe5692 100644 --- a/packages/excubiae/contracts/extensions/EASExcubia.sol +++ b/packages/excubiae/contracts/extensions/EASExcubia.sol @@ -65,8 +65,7 @@ contract EASExcubia is Excubia { /// @dev Checks if the attestation matches the schema, attester, recipient, and is not revoked. /// @param passerby The address of the entity attempting to pass the gate. /// @param data Additional data required for the check (e.g., encoded attestation ID). - /// @return True if the attestation is valid and the passerby passes the check, false otherwise. - function _check(address passerby, bytes calldata data) internal view override returns (bool) { + function _check(address passerby, bytes calldata data) internal view override { super._check(passerby, data); bytes32 attestationId = abi.decode(data, (bytes32)); @@ -77,7 +76,5 @@ contract EASExcubia is Excubia { if (attestation.attester != ATTESTER) revert UnexpectedAttester(); if (attestation.recipient != passerby) revert UnexpectedRecipient(); if (attestation.revocationTime != 0) revert RevokedAttestation(); - - return true; } } diff --git a/packages/excubiae/contracts/extensions/ERC721Excubia.sol b/packages/excubiae/contracts/extensions/ERC721Excubia.sol index f3b1e0b..8e93dc7 100644 --- a/packages/excubiae/contracts/extensions/ERC721Excubia.sol +++ b/packages/excubiae/contracts/extensions/ERC721Excubia.sol @@ -46,15 +46,12 @@ contract ERC721Excubia is Excubia { /// @dev Checks if the passerby is the owner of the token. /// @param passerby The address of the entity attempting to pass the gate. /// @param data Additional data required for the check (e.g., encoded token ID). - /// @return True if the passerby owns the token, false otherwise. - function _check(address passerby, bytes calldata data) internal view override returns (bool) { + function _check(address passerby, bytes calldata data) internal view override { super._check(passerby, data); uint256 tokenId = abi.decode(data, (uint256)); // Check if the user owns the token. if (!(NFT.ownerOf(tokenId) == passerby)) revert UnexpectedTokenOwner(); - - return true; } } diff --git a/packages/excubiae/contracts/extensions/FreeForAllExcubia.sol b/packages/excubiae/contracts/extensions/FreeForAllExcubia.sol index 0d7f5ad..936566d 100644 --- a/packages/excubiae/contracts/extensions/FreeForAllExcubia.sol +++ b/packages/excubiae/contracts/extensions/FreeForAllExcubia.sol @@ -31,10 +31,7 @@ contract FreeForAllExcubia is Excubia { /// @dev This function always returns true, signaling that any passerby is able to pass the gate. /// @param passerby The address of the entity attempting to pass the gate. /// @param data Additional data required for the check (e.g., encoded attestation ID). - /// @return True, allowing any passerby to pass the gate. - function _check(address passerby, bytes calldata data) internal view override returns (bool) { + function _check(address passerby, bytes calldata data) internal view override { super._check(passerby, data); - - return true; } } diff --git a/packages/excubiae/test/EASExcubia.test.ts b/packages/excubiae/test/EASExcubia.test.ts index 3c040c8..a74a8f1 100644 --- a/packages/excubiae/test/EASExcubia.test.ts +++ b/packages/excubiae/test/EASExcubia.test.ts @@ -125,9 +125,8 @@ describe("EASExcubia", function () { }) it("should pass the check", async () => { - const passed = await easExcubia.check(signerAddress, validAttestationId) + await expect(easExcubia.check(signerAddress, validAttestationId)).to.not.be.reverted - expect(passed).to.be.true // check does NOT change the state of the contract (see pass()). expect(await easExcubia.registeredAttestations(validAttestationId)).to.be.false }) diff --git a/packages/excubiae/test/ERC721Excubia.test.ts b/packages/excubiae/test/ERC721Excubia.test.ts index 24a3c90..f527e0b 100644 --- a/packages/excubiae/test/ERC721Excubia.test.ts +++ b/packages/excubiae/test/ERC721Excubia.test.ts @@ -110,9 +110,8 @@ describe("ERC721Excubia", function () { }) it("should check", async () => { - const passed = await erc721Excubia.check(signerAddress, encodedValidTokenId) + await expect(erc721Excubia.check(signerAddress, encodedValidTokenId)).to.not.be.reverted - expect(passed).to.be.true // check does NOT change the state of the contract (see pass()). expect(await erc721Excubia.registeredTokenIds(rawValidTokenId)).to.be.false }) diff --git a/packages/excubiae/test/FreeForAllExcubia.test.ts b/packages/excubiae/test/FreeForAllExcubia.test.ts index f9bd94f..e6ccfac 100644 --- a/packages/excubiae/test/FreeForAllExcubia.test.ts +++ b/packages/excubiae/test/FreeForAllExcubia.test.ts @@ -72,9 +72,8 @@ describe("FreeForAllExcubia", function () { describe("check()", function () { it("should check", async () => { // `data` parameter value can be whatever (e.g., ZeroHash default). - const passed = await freeForAllExcubia.check(signerAddress, ZeroHash) + await expect(freeForAllExcubia.check(signerAddress, ZeroHash)).to.not.be.reverted - expect(passed).to.be.true // check does NOT change the state of the contract (see pass()). expect(await freeForAllExcubia.registeredPassersby(signerAddress)).to.be.false })