Skip to content

Commit

Permalink
Merge pull request #652 from morpho-org/fix/revert-already-set
Browse files Browse the repository at this point in the history
fix(authorization): revert already set error
  • Loading branch information
MerlinEgalite authored Dec 20, 2023
2 parents 5afa588 + b2279f2 commit 24b4d02
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
5 changes: 1 addition & 4 deletions src/Morpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,7 @@ contract Morpho is IMorphoStaticTyping {

/// @inheritdoc IMorphoBase
function setAuthorizationWithSig(Authorization memory authorization, Signature calldata signature) external {
require(
authorization.isAuthorized != isAuthorized[authorization.authorizer][authorization.authorized],
ErrorsLib.ALREADY_SET
);
/// Do not check whether authorization is already set because the nonce increment is a desired side effect.
require(block.timestamp <= authorization.deadline, ErrorsLib.SIGNATURE_EXPIRED);
require(authorization.nonce == nonce[authorization.authorizer]++, ErrorsLib.INVALID_NONCE);

Expand Down
16 changes: 0 additions & 16 deletions test/forge/integration/AuthorizationIntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ contract AuthorizationIntegrationTest is BaseTest {
morpho.setAuthorization(addressFuzz, true);
}

function testAlreadySetWithSig(Authorization memory authorization, Signature memory sig) public {
authorization.isAuthorized = false;
authorization.authorizer = address(this);
authorization.deadline = block.timestamp;
authorization.nonce = 0;

vm.expectRevert(bytes(ErrorsLib.ALREADY_SET));
morpho.setAuthorizationWithSig(authorization, sig);

morpho.setAuthorization(authorization.authorized, true);

authorization.isAuthorized = true;
vm.expectRevert(bytes(ErrorsLib.ALREADY_SET));
morpho.setAuthorizationWithSig(authorization, sig);
}

function testSetAuthorizationWithSignatureDeadlineOutdated(
Authorization memory authorization,
uint256 privateKey,
Expand Down

0 comments on commit 24b4d02

Please sign in to comment.