Skip to content

Commit

Permalink
chore: minor improvements after reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Aug 19, 2023
1 parent a331784 commit d94a631
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Morpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract Morpho is IMorpho {
/// @inheritdoc IMorpho
mapping(address => mapping(address => bool)) public isAuthorized;
/// @inheritdoc IMorpho
mapping(address => uint256) public authorizationNonce;
mapping(address => uint256) public nonce;
/// @inheritdoc IMorpho
mapping(Id => MarketParams) public idToMarketParams;

Expand Down Expand Up @@ -409,7 +409,7 @@ contract Morpho is IMorpho {
/// @dev The nonce is passed as argument to be able to revert with a different error message.
function setAuthorizationWithSig(Authorization memory authorization, Signature calldata signature) external {
require(block.timestamp < authorization.deadline, ErrorsLib.SIGNATURE_EXPIRED);
require(authorization.nonce == authorizationNonce[authorization.authorizer]++, ErrorsLib.INVALID_NONCE);
require(authorization.nonce == nonce[authorization.authorizer]++, ErrorsLib.INVALID_NONCE);

bytes32 hashStruct = keccak256(abi.encode(AUTHORIZATION_TYPEHASH, authorization));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, hashStruct));
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/IMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ interface IMorpho {
function DOMAIN_SEPARATOR() external view returns (bytes32);

/// @notice The owner of the contract.
/// @dev They have the power to change the owner.
/// @dev They have the power to set fees on markets and set the fee recipient.
/// @dev They have the power to enable but not disable IRMs and LLTVs.
/// @dev It has the power to change the owner.
/// @dev It has the power to set fees on markets and set the fee recipient.
/// @dev It has the power to enable but not disable IRMs and LLTVs.
function owner() external view returns (address);

/// @notice The fee recipient of all markets.
Expand All @@ -79,7 +79,7 @@ interface IMorpho {
function isAuthorized(address authorizer, address authorized) external view returns (bool);

/// @notice The `authorizer`'s current nonce. Used to prevent replay attacks with EIP-712 signatures.
function authorizationNonce(address authorizer) external view returns (uint256);
function nonce(address authorizer) external view returns (uint256);

/// @notice The market params corresponding to `id`.
function idToMarketParams(Id id)
Expand Down
5 changes: 5 additions & 0 deletions test/forge/integration/TestIntegrationOnlyOwner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ contract IntegrationOnlyOwnerTest is BaseTest {
using MathLib for uint256;
using MorphoLib for Morpho;

function testDeployWithAddressZero() public {
vm.expectRevert();
new Morpho(address(0));
}

function testSetOwnerWhenNotOwner(address addressFuzz) public {
vm.assume(addressFuzz != OWNER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ contract IntegrationAuthorization is BaseTest {
morpho.setAuthorizationWithSig(authorization, sig);

assertEq(morpho.isAuthorized(authorization.authorizer, authorization.authorized), authorization.isAuthorized);
assertEq(morpho.authorizationNonce(authorization.authorizer), 1);
assertEq(morpho.nonce(authorization.authorizer), 1);
}
}
2 changes: 1 addition & 1 deletion test/forge/periphery/MorphoStorageLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract MorphoStorageLibTest is BaseTest {
assertEq(abi.decode(abi.encode(values[7]), (bool)), morpho.isIrmEnabled(address(irm)));
assertEq(abi.decode(abi.encode(values[8]), (bool)), morpho.isLltvEnabled(LLTV));
assertEq(abi.decode(abi.encode(values[9]), (bool)), morpho.isAuthorized(authorizer, BORROWER));
assertEq(uint256(values[10]), morpho.authorizationNonce(authorizer));
assertEq(uint256(values[10]), morpho.nonce(authorizer));

(
address expectedBorrowableToken,
Expand Down

0 comments on commit d94a631

Please sign in to comment.