Skip to content

Commit 5edcfcb

Browse files
committed
Apply audit review suggestions
1 parent a67fa52 commit 5edcfcb

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

contracts/crosschain/axelar/AxelarGatewayBase.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract contract AxelarGatewayBase is Ownable {
4242
require(bytes(output).length > 0, UnsupportedChain(input));
4343
}
4444

45-
/// @dev Returns the CAIP-10 account address of the remote gateway for a given CAIP-2 chain identifier.
45+
/// @dev Returns the address string of the remote gateway for a given CAIP-2 chain identifier.
4646
function getRemoteGateway(string memory caip2) public view virtual returns (string memory remoteGateway) {
4747
remoteGateway = _remoteGateways[caip2];
4848
require(bytes(remoteGateway).length > 0, UnsupportedChain(caip2));
@@ -56,7 +56,7 @@ abstract contract AxelarGatewayBase is Ownable {
5656
emit RegisteredChainEquivalence(caip2, axelarSupported);
5757
}
5858

59-
/// @dev Registers the CAIP-10 account address of the remote gateway for a given CAIP-2 chain identifier.
59+
/// @dev Registers the address string of the remote gateway for a given CAIP-2 chain identifier.
6060
function registerRemoteGateway(string calldata caip2, string calldata remoteGateway) public virtual onlyOwner {
6161
require(bytes(_remoteGateways[caip2]).length == 0, RemoteGatewayAlreadyRegistered(caip2));
6262
_remoteGateways[caip2] = remoteGateway;

contracts/crosschain/axelar/AxelarGatewayDestination.sol

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ abstract contract AxelarGatewayDestination is IERC7786GatewayDestinationPassive,
2121
error InvalidOriginGateway(string sourceChain, string axelarSourceAddress);
2222
error ReceiverExecutionFailed();
2323

24-
/// @dev Sets a message as executed so it can't be executed again. Should be called by the receiver contract.
24+
/**
25+
* @dev Sets a message as executed so it can't be executed again. Should be called by the receiver contract.
26+
* @param sourceChain {CAIP2} chain identifier
27+
* @param sender {CAIP10} account address (does not include the chain identifier)
28+
*/
2529
function setMessageExecuted(
2630
bytes calldata messageKey,
27-
string calldata sourceChain, // CAIP-2 chain identifier
28-
string calldata sender, // CAIP-10 account address (does not include the chain identifier)
31+
string calldata sourceChain,
32+
string calldata sender,
2933
bytes calldata payload,
3034
bytes[] calldata attributes
3135
) external {

contracts/crosschain/axelar/AxelarGatewayDuplex.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {AxelarGatewayBase, IAxelarGateway} from "./AxelarGatewayBase.sol";
77
import {AxelarGatewayDestination, AxelarExecutable} from "./AxelarGatewayDestination.sol";
88
import {AxelarGatewaySource} from "./AxelarGatewaySource.sol";
99

10+
/**
11+
* @dev A contract that combines the functionality of both the source and destination gateway
12+
* adapters for the Axelar Network. Allowing to either send or receive messages across chains.
13+
*/
1014
contract AxelarGatewayDuplex is AxelarGatewaySource, AxelarGatewayDestination {
15+
/// @dev Initializes the contract with the Axelar gateway and the initial owner.
1116
constructor(
1217
IAxelarGateway gateway,
1318
address initialOwner

contracts/crosschain/axelar/AxelarGatewaySource.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract contract AxelarGatewaySource is IERC7786GatewaySource, AxelarGatewayBas
3030
string calldata receiver, // CAIP-10 account address (does not include the chain identifier)
3131
bytes calldata payload,
3232
bytes[] calldata attributes
33-
) external payable returns (bytes32) {
33+
) external payable returns (bytes32 outboxId) {
3434
require(msg.value == 0, SendingValueNotSupported());
3535
if (attributes.length > 0)
3636
revert UnsupportedAttribute(attributes[0].length < 0x04 ? bytes4(0) : bytes4(attributes[0][0:4]));
@@ -40,8 +40,9 @@ abstract contract AxelarGatewaySource is IERC7786GatewaySource, AxelarGatewayBas
4040
bytes memory adapterPayload = abi.encode(sender, receiver, payload, attributes);
4141

4242
// Emit event
43+
outboxId = bytes32(0); // Explicitly set to 0
4344
emit MessagePosted(
44-
0,
45+
outboxId,
4546
CAIP10.format(CAIP2.local(), sender),
4647
CAIP10.format(destinationChain, receiver),
4748
payload,
@@ -53,6 +54,6 @@ abstract contract AxelarGatewaySource is IERC7786GatewaySource, AxelarGatewayBas
5354
string memory remoteGateway = getRemoteGateway(destinationChain);
5455
localGateway.callContract(axelarDestination, remoteGateway, adapterPayload);
5556

56-
return 0;
57+
return outboxId;
5758
}
5859
}

contracts/crosschain/interfaces/draft-IERC7786.sol

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ interface IERC7786GatewaySource {
3030
* @dev Endpoint for creating a new message. If the message requires further (gateway specific) processing before
3131
* it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the
3232
* message MUST be sent and this function must return 0.
33+
* @param destinationChain {CAIP2} chain identifier
34+
* @param receiver {CAIP10} account address (does not include the chain identifier)
3335
*
34-
* * MUST emit a {MessageCreated} event.
36+
* * MUST emit a {MessagePosted} event.
3537
*
3638
* If any of the `attributes` is not supported, this function SHOULD revert with an {UnsupportedAttribute} error.
3739
* Other errors SHOULD revert with errors not specified in ERC-7786.
3840
*/
3941
function sendMessage(
40-
string calldata destinationChain, // CAIP-2 chain identifier
41-
string calldata receiver, // CAIP-10 account address (does not include the chain identifier)
42+
string calldata destinationChain,
43+
string calldata receiver,
4244
bytes calldata payload,
4345
bytes[] calldata attributes
4446
) external payable returns (bytes32 outboxId);
@@ -56,14 +58,16 @@ interface IERC7786GatewayDestinationPassive {
5658
* @dev Endpoint for checking the validity of a message that is being relayed in passive mode. The message
5759
* receiver is implicitly the caller of this method, which guarantees that no one but the receiver can
5860
* "consume" the message. This function MUST implement replay protection, meaning that if called multiple time
59-
* for same message, all but the first calls MUST revert.
61+
* for same message, all but the first calls MUST revert.'
62+
* @param sourceChain {CAIP2} chain identifier
63+
* @param sender {CAIP10} account address (does not include the chain identifier)
6064
*
6165
* NOTE: implementing this interface is OPTIONAL. Some destination gateway MAY only support active mode.
6266
*/
6367
function setMessageExecuted(
6468
bytes calldata messageKey,
65-
string calldata sourceChain, // CAIP-2 chain identifier
66-
string calldata sender, // CAIP-10 account address (does not include the chain identifier)
69+
string calldata sourceChain,
70+
string calldata sender,
6771
bytes calldata payload,
6872
bytes[] calldata attributes
6973
) external;
@@ -77,14 +81,16 @@ interface IERC7786GatewayDestinationPassive {
7781
interface IERC7786Receiver {
7882
/**
7983
* @dev Endpoint for receiving cross-chain message.
84+
* @param sourceChain {CAIP2} chain identifier
85+
* @param sender {CAIP10} account address (does not include the chain identifier)
8086
*
8187
* This function may be called directly by the gateway (active mode) or by a third party (passive mode).
8288
*/
8389
function executeMessage(
8490
address gateway,
8591
bytes calldata gatewayMessageKey,
86-
string calldata sourceChain, // CAIP-2 chain identifier
87-
string calldata sender, // CAIP-10 account address (does not include the chain identifier)
92+
string calldata sourceChain,
93+
string calldata sender,
8894
bytes calldata payload,
8995
bytes[] calldata attributes
9096
) external payable returns (bytes4);

contracts/crosschain/utils/draft-ERC7786Receiver.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ abstract contract ERC7786Receiver is IERC7786Receiver {
2424
function executeMessage(
2525
address gateway,
2626
bytes calldata gatewayMessageKey,
27-
string calldata source,
28-
string calldata sender,
27+
string calldata sourceChain, // CAIP-2 chain identifier
28+
string calldata sender, // CAIP-10 account address (does not include the chain identifier)
2929
bytes calldata payload,
3030
bytes[] calldata attributes
3131
) public payable virtual returns (bytes4) {
@@ -37,15 +37,15 @@ abstract contract ERC7786Receiver is IERC7786Receiver {
3737
require(msg.value == 0, ERC7786ReceivePassiveModeValue());
3838
IERC7786GatewayDestinationPassive(gateway).setMessageExecuted(
3939
gatewayMessageKey,
40-
source,
40+
sourceChain,
4141
sender,
4242
payload,
4343
attributes
4444
);
4545
} else {
4646
revert ERC7786ReceiverInvalidGateway(gateway);
4747
}
48-
_processMessage(gateway, source, sender, payload, attributes);
48+
_processMessage(gateway, sourceChain, sender, payload, attributes);
4949
return IERC7786Receiver.executeMessage.selector;
5050
}
5151

@@ -55,7 +55,7 @@ abstract contract ERC7786Receiver is IERC7786Receiver {
5555
/// @dev Virtual function that should contain the logic to execute when a cross-chain message is received.
5656
function _processMessage(
5757
address gateway,
58-
string calldata source,
58+
string calldata sourceChain,
5959
string calldata sender,
6060
bytes calldata payload,
6161
bytes[] calldata attributes

0 commit comments

Comments
 (0)