diff --git a/apps/blockchain/ethereum/src/Bridge.sol b/apps/blockchain/ethereum/src/Bridge.sol index 078ac40b..e760e522 100644 --- a/apps/blockchain/ethereum/src/Bridge.sol +++ b/apps/blockchain/ethereum/src/Bridge.sol @@ -13,6 +13,7 @@ import "./Messaging.sol"; import "./UUPSProxied.sol"; import "starknet/IStarknetMessaging.sol"; +import "openzeppelin-contracts/contracts/proxy/utils/Initializable.sol"; import "./IStarklaneEvent.sol"; @@ -50,9 +51,12 @@ contract Starklane is /** * @notice Initializes the implementation, only callable once. - * - * @param data Data to init the implementation. */ + + constructor() { + _disableInitializers(); + } + function initialize(bytes calldata data) public onlyInit { ( address owner, diff --git a/apps/blockchain/ethereum/test/Bridge.t.sol b/apps/blockchain/ethereum/test/Bridge.t.sol index 0c28795e..59934885 100644 --- a/apps/blockchain/ethereum/test/Bridge.t.sol +++ b/apps/blockchain/ethereum/test/Bridge.t.sol @@ -55,6 +55,25 @@ contract BridgeTest is Test, IStarklaneEvent { IStarklane(bridge).enableBridge(true); } + // + function test_initializersDisabled() public { + // Deploy a new instance of Starklane + Starklane newStarklane = new Starklane(); + + // Try to initialize the contract directly + bytes memory initData = abi.encode( + address(this), + address(0), // Mock Starknet Core address + uint256(0), // Mock Starklane L2 address + uint256(0) // Mock Starklane L2 selector + ); + + // Expect the initialization to revert + vm.expectRevert("Initializable: contract is already initialized"); + newStarklane.initialize(initData); + } + + // function testFail_invalidIds() public { uint256[] memory ids = new uint256[](0);