diff --git a/contracts/MapleLoanV502Migrator.sol b/contracts/MapleLoanV502Migrator.sol index 2b29fda..af8600f 100644 --- a/contracts/MapleLoanV502Migrator.sol +++ b/contracts/MapleLoanV502Migrator.sol @@ -9,10 +9,12 @@ import { MapleLoanStorage } from "./MapleLoanStorage.sol"; /// @title MapleLoanV502Migrator is to update the factory address for each deployed loan. contract MapleLoanV502Migrator is ProxiedInternals, MapleLoanStorage { - + fallback() external { ( address newFactory_ ) = abi.decode(msg.data, (address)); + require(_factory() != newFactory_, "MLV502M:INVALID_NO_OP"); + address globals = IMapleProxyFactoryLike(_factory()).mapleGlobals(); require(IGlobalsLike(globals).isInstanceOf("FT_LOAN_FACTORY", newFactory_), "MLV502M:INVALID_FACTORY"); diff --git a/tests/MapleLoanV502Migrator.t.sol b/tests/MapleLoanV502Migrator.t.sol index f6a39a5..102bb00 100644 --- a/tests/MapleLoanV502Migrator.t.sol +++ b/tests/MapleLoanV502Migrator.t.sol @@ -86,6 +86,16 @@ contract MapleLoanV502MigratorTests is TestUtils { loan502 = MapleLoan(oldFactory.createInstance(arguments, "SALT2")); } + function test_migration_sameFactory_noOp() external { + newFactory = new MapleLoanFactory(address(globals), address(oldFactory)); + + bytes memory arguments = abi.encode(address(oldFactory)); + + vm.expectRevert("MPF:UI:FAILED"); + vm.prank(securityAdmin); + loan501.upgrade(502, arguments); + } + function test_migration_invalidFactory() external { newFactory = new MapleLoanFactory(address(globals), address(oldFactory));