From 786d6296972ba0b77290512d1ba22d23a5e2ea18 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 20 Nov 2024 20:27:16 +0300 Subject: [PATCH] gateway revert --- examples/call/contracts/Universal.sol | 4 +++- examples/hello/contracts/Universal.sol | 3 ++- examples/swap/contracts/Swap.sol | 3 ++- examples/swap/contracts/SwapToAnyToken.sol | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/call/contracts/Universal.sol b/examples/call/contracts/Universal.sol index 5b9f6c05..df362796 100644 --- a/examples/call/contracts/Universal.sol +++ b/examples/call/contracts/Universal.sol @@ -11,10 +11,12 @@ contract Universal is UniversalContract { event HelloEvent(string, string); event RevertEvent(string, RevertContext); + error TransferFailed(); + error Unauthorized(); modifier onlyGateway() { - require(msg.sender == address(gateway), "Caller is not the gateway"); + if (msg.sender != address(gateway)) revert Unauthorized(); _; } diff --git a/examples/hello/contracts/Universal.sol b/examples/hello/contracts/Universal.sol index b83fc684..fa4920e9 100644 --- a/examples/hello/contracts/Universal.sol +++ b/examples/hello/contracts/Universal.sol @@ -7,9 +7,10 @@ contract Universal is UniversalContract { GatewayZEVM public immutable gateway; event HelloEvent(string, string); + error Unauthorized(); modifier onlyGateway() { - require(msg.sender == address(gateway), "Caller is not the gateway"); + if (msg.sender != address(gateway)) revert Unauthorized(); _; } diff --git a/examples/swap/contracts/Swap.sol b/examples/swap/contracts/Swap.sol index f8c1ebf5..d6c8ade1 100644 --- a/examples/swap/contracts/Swap.sol +++ b/examples/swap/contracts/Swap.sol @@ -17,9 +17,10 @@ contract Swap is UniversalContract { uint256 constant BITCOIN = 18332; error InvalidAddress(); + error Unauthorized(); modifier onlyGateway() { - require(msg.sender == address(gateway), "Caller is not the gateway"); + if (msg.sender != address(gateway)) revert Unauthorized(); _; } diff --git a/examples/swap/contracts/SwapToAnyToken.sol b/examples/swap/contracts/SwapToAnyToken.sol index 9642687b..d3022c99 100644 --- a/examples/swap/contracts/SwapToAnyToken.sol +++ b/examples/swap/contracts/SwapToAnyToken.sol @@ -16,10 +16,12 @@ contract SwapToAnyToken is UniversalContract { address public immutable uniswapRouter; GatewayZEVM public gateway; uint256 constant BITCOIN = 18332; + error InvalidAddress(); + error Unauthorized(); modifier onlyGateway() { - require(msg.sender == address(gateway), "Caller is not the gateway"); + if (msg.sender != address(gateway)) revert Unauthorized(); _; }