1
1
// SPDX-License-Identifier: MIT
2
2
3
- pragma solidity ^ 0.8.0 ;
3
+ pragma solidity ^ 0.8.27 ;
4
4
5
5
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol " ;
6
6
import {IAxelarGateway} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol " ;
@@ -22,6 +22,9 @@ abstract contract AxelarGatewayBase is Ownable {
22
22
/// @dev Error emitted when an unsupported chain is queried.
23
23
error UnsupportedChain (string caip2 );
24
24
25
+ error ChainEquivalenceAlreadyRegistered (string caip2 );
26
+ error RemoteGatewayAlreadyRegistered (string caip2 );
27
+
25
28
/// @dev Axelar's official gateway for the current chain.
26
29
IAxelarGateway public immutable localGateway;
27
30
@@ -36,26 +39,26 @@ abstract contract AxelarGatewayBase is Ownable {
36
39
/// @dev Returns the equivalent chain given an id that can be either CAIP-2 or an Axelar network identifier.
37
40
function getEquivalentChain (string memory input ) public view virtual returns (string memory output ) {
38
41
output = _chainEquivalence[input];
39
- if (bytes (output).length == 0 ) revert UnsupportedChain (input);
42
+ require (bytes (output).length > 0 , UnsupportedChain (input) );
40
43
}
41
44
42
45
/// @dev Returns the CAIP-10 account address of the remote gateway for a given CAIP-2 chain identifier.
43
46
function getRemoteGateway (string memory caip2 ) public view virtual returns (string memory remoteGateway ) {
44
47
remoteGateway = _remoteGateways[caip2];
45
- if (bytes (remoteGateway).length == 0 ) revert UnsupportedChain (caip2);
48
+ require (bytes (remoteGateway).length > 0 , UnsupportedChain (caip2) );
46
49
}
47
50
48
51
/// @dev Registers a chain equivalence between a CAIP-2 chain identifier and an Axelar network identifier.
49
52
function registerChainEquivalence (string calldata caip2 , string calldata axelarSupported ) public virtual onlyOwner {
50
- require (bytes (_chainEquivalence[caip2]).length == 0 , " Chain equivalence already registered " );
53
+ require (bytes (_chainEquivalence[caip2]).length == 0 , ChainEquivalenceAlreadyRegistered (caip2) );
51
54
_chainEquivalence[caip2] = axelarSupported;
52
55
_chainEquivalence[axelarSupported] = caip2;
53
56
emit RegisteredChainEquivalence (caip2, axelarSupported);
54
57
}
55
58
56
59
/// @dev Registers the CAIP-10 account address of the remote gateway for a given CAIP-2 chain identifier.
57
60
function registerRemoteGateway (string calldata caip2 , string calldata remoteGateway ) public virtual onlyOwner {
58
- require (bytes (_remoteGateways[caip2]).length == 0 , " Remote gateway already registered " );
61
+ require (bytes (_remoteGateways[caip2]).length == 0 , RemoteGatewayAlreadyRegistered (caip2) );
59
62
_remoteGateways[caip2] = remoteGateway;
60
63
emit RegisteredRemoteGateway (caip2, remoteGateway);
61
64
}
0 commit comments