From 4c90c6a6ed347a049a2a50f0e94caba9471747e6 Mon Sep 17 00:00:00 2001 From: josojo Date: Fri, 3 Nov 2023 09:19:44 +0100 Subject: [PATCH] Deactivate to send eth in messageBridge function (#27) --- .../inheritedMainContracts/PolygonZkEVMBridge.sol | 2 +- test/contracts/bridge.test.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/contracts/inheritedMainContracts/PolygonZkEVMBridge.sol b/contracts/inheritedMainContracts/PolygonZkEVMBridge.sol index c6227b6e5..62acd96d7 100644 --- a/contracts/inheritedMainContracts/PolygonZkEVMBridge.sol +++ b/contracts/inheritedMainContracts/PolygonZkEVMBridge.sol @@ -289,7 +289,7 @@ contract PolygonZkEVMBridge is bool forceUpdateGlobalExitRoot, bytes calldata metadata ) public virtual payable ifNotEmergencyState { - if (msg.value != 0 && !isDeployedOnL2) { + if (msg.value != 0) { revert MsgValueNotZero(); } if ( diff --git a/test/contracts/bridge.test.js b/test/contracts/bridge.test.js index 3736e988e..2218d1e37 100644 --- a/test/contracts/bridge.test.js +++ b/test/contracts/bridge.test.js @@ -185,7 +185,7 @@ describe('PolygonZkEVMBridge Contract - for L2', () => { const depositCount = await polygonZkEVMBridgeContract.depositCount(); const originNetwork = networkIDMainnet; const originAddress = deployer.address; - const amount = ethers.utils.parseEther('10'); + const amount = ethers.utils.parseEther('0'); const destinationNetwork = networkIDRollup; const destinationAddress = deployer.address; @@ -246,7 +246,7 @@ describe('PolygonZkEVMBridge Contract - for L2', () => { const depositCount = await polygonZkEVMBridgeContract.depositCount(); const originNetwork = networkIDMainnet; const tokenAddress = tokenContract.address; - const amount = ethers.utils.parseEther('10'); + const amount = ethers.utils.parseEther('0'); const destinationNetwork = networkIDRollup; const destinationAddress = deployer.address; @@ -1193,6 +1193,16 @@ describe('PolygonZkEVMBridge Contract - for L2', () => { metadata, )).to.be.revertedWith('AlreadyClaimed'); }); + it('should not allow to send message with ether', async () => { + const amount = ethers.utils.parseEther('10'); + await expect(polygonZkEVMBridgeContract.bridgeMessage( + networkIDRollup, + ethers.constants.AddressZero, + true, + '0x', + { value: amount }, + )).to.be.revertedWith('MsgValueNotZero()'); + }); }); describe('PolygonZkEVMBridge Contract - for L1', () => {