Browse Source

Add custom error to `CrossChainEnabledPolygonChild` (#3380)

Pascal Marco Caversaccio 3 years ago
parent
commit
be3cfa0f90
2 changed files with 3 additions and 2 deletions
  1. 1 0
      CHANGELOG.md
  2. 2 2
      contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 
  * `Clones`: optimize clone creation ([#3329](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3329))
  * `TimelockController`: Migrate `_call` to `_execute` and allow inheritance and overriding similar to `Governor`. ([#3317](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3317))
+ * `CrossChainEnabledPolygonChild`: replace the `require` statement with the custom error `NotCrossChainCall`. ([#3380](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3380))
 
 ## 4.6.0 (2022-04-26)
 

+ 2 - 2
contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol

@@ -63,10 +63,10 @@ abstract contract CrossChainEnabledPolygonChild is IFxMessageProcessor, CrossCha
         address rootMessageSender,
         bytes calldata data
     ) external override nonReentrant {
-        require(msg.sender == _fxChild, "unauthorized cross-chain relay");
+        if (!_isCrossChain()) revert NotCrossChainCall();
 
         _sender = rootMessageSender;
-        Address.functionDelegateCall(address(this), data, "crosschain execution failled");
+        Address.functionDelegateCall(address(this), data, "cross-chain execution failed");
         _sender = DEFAULT_SENDER;
     }
 }