Skip to content

Commit 84f87be

Browse files
committed
add missing docstrings
Signed-off-by: Ihor Farion <ihor@umaproject.org>
1 parent f2d0115 commit 84f87be

File tree

3 files changed

+63
-15
lines changed

3 files changed

+63
-15
lines changed

contracts/AdapterStore.sol

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
55
import { IOFT } from "./interfaces/IOFT.sol";
66

77
/**
8+
* @title MessengerTypes
9+
* @notice Library containing messenger type constants
810
* @custom:security-contact bugs@across.to
911
*/
1012
library MessengerTypes {
13+
/** @notice Identifier for OFT (Omni-chain Fungible Token by LayerZero) messenger type */
1114
bytes32 public constant OFT_MESSENGER = bytes32("OFT_MESSENGER");
1215
}
1316

@@ -18,20 +21,39 @@ library MessengerTypes {
1821
* @custom:security-contact bugs@across.to
1922
*/
2023
contract AdapterStore is Ownable {
21-
// (messengerType, dstDomainId, srcChainToken) => messenger address
24+
/** @notice Maps messenger type and destination domain to token-messenger pairs */
2225
mapping(bytes32 => mapping(uint256 => mapping(address => address))) public crossChainMessengers;
2326

27+
/**
28+
* @notice Emitted when a messenger is set for a specific token and destination
29+
* @param messengerType Type of messenger being set
30+
* @param dstDomainId Destination domain ID
31+
* @param srcChainToken Source chain token address
32+
* @param srcChainMessenger Source chain messenger address
33+
*/
2434
event MessengerSet(
2535
bytes32 indexed messengerType,
2636
uint256 indexed dstDomainId,
2737
address indexed srcChainToken,
2838
address srcChainMessenger
2939
);
3040

41+
/** @notice Thrown when array lengths don't match in batch operations */
3142
error ArrayLengthMismatch();
43+
44+
/** @notice Thrown when IOFT messenger's token doesn't match expected token */
3245
error IOFTTokenMismatch();
46+
47+
/** @notice Thrown when messenger type is not supported */
3348
error NonExistentMessengerType();
3449

50+
/**
51+
* @notice Sets a messenger for a specific token and destination domain
52+
* @param messengerType Type of messenger to set
53+
* @param dstDomainId Destination domain ID
54+
* @param srcChainToken Source chain token address
55+
* @param srcChainMessenger Source chain messenger address
56+
*/
3557
function setMessenger(
3658
bytes32 messengerType,
3759
uint256 dstDomainId,
@@ -41,6 +63,13 @@ contract AdapterStore is Ownable {
4163
_setMessenger(messengerType, dstDomainId, srcChainToken, srcChainMessenger);
4264
}
4365

66+
/**
67+
* @notice Sets multiple messengers in a single transaction
68+
* @param messengerTypes Array of messenger types
69+
* @param dstDomainIds Array of destination domain IDs
70+
* @param srcChainTokens Array of source chain token addresses
71+
* @param srcChainMessengers Array of source chain messenger addresses
72+
*/
4473
function batchSetMessengers(
4574
bytes32[] calldata messengerTypes,
4675
uint256[] calldata dstDomainIds,
@@ -60,6 +89,13 @@ contract AdapterStore is Ownable {
6089
}
6190
}
6291

92+
/**
93+
* @notice Internal function to set a messenger with validation
94+
* @param _messengerType Type of messenger to set
95+
* @param _dstDomainId Destination domain ID
96+
* @param _srcChainToken Source chain token address
97+
* @param _srcChainMessenger Source chain messenger address
98+
*/
6399
function _setMessenger(
64100
bytes32 _messengerType,
65101
uint256 _dstDomainId,

contracts/libraries/OFTTransportAdapter.sol

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ contract OFTTransportAdapter {
1515
using SafeERC20 for IERC20;
1616
using AddressToBytes32 for address;
1717

18+
/** @notice Empty bytes array used for OFT messaging parameters */
1819
bytes public constant EMPTY_MSG_BYTES = new bytes(0);
1920

2021
/**
21-
* @dev a fee cap we check against before sending a message with value to OFTMessenger as fees.
22-
* @dev this cap should be pretty conservative (high) to not interfere with operations under normal conditions.
22+
* @notice Fee cap checked before sending messages to OFTMessenger
23+
* @dev Conservative (high) cap to not interfere with operations under normal conditions
2324
*/
2425
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
2526
uint256 public immutable OFT_FEE_CAP;
@@ -31,10 +32,19 @@ contract OFTTransportAdapter {
3132
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
3233
uint32 public immutable OFT_DST_EID;
3334

35+
/** @notice Thrown when OFT fee exceeds the configured cap */
3436
error OftFeeCapExceeded();
37+
38+
/** @notice Thrown when contract has insufficient balance to pay OFT fees */
3539
error OftInsufficientBalanceForFee();
40+
41+
/** @notice Thrown when LayerZero token fee is not zero (only native fees supported) */
3642
error OftLzFeeNotZero();
43+
44+
/** @notice Thrown when amount received differs from expected amount */
3745
error OftIncorrectAmountReceivedLD();
46+
47+
/** @notice Thrown when amount sent differs from expected amount */
3848
error OftIncorrectAmountSentLD();
3949

4050
/**
@@ -56,12 +66,7 @@ contract OFTTransportAdapter {
5666
* @param _to address to receive a transfer on the destination chain.
5767
* @param _amount amount to send.
5868
*/
59-
function _transferViaOFT(
60-
IERC20 _token,
61-
IOFT _messenger,
62-
address _to,
63-
uint256 _amount
64-
) internal {
69+
function _transferViaOFT(IERC20 _token, IOFT _messenger, address _to, uint256 _amount) internal {
6570
bytes32 to = _to.toBytes32();
6671

6772
SendParam memory sendParam = SendParam(

contracts/libraries/OFTTransportAdapterWithStore.sol

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@ import { AdapterStore, MessengerTypes } from "../AdapterStore.sol";
99
* @custom:security-contact bugs@across.to
1010
*/
1111
contract OFTTransportAdapterWithStore is OFTTransportAdapter {
12-
// Helper storage contract to keep track of token => IOFT relationships
12+
/** @notice Helper storage contract to keep track of token => IOFT relationships */
1313
AdapterStore public immutable OFT_ADAPTER_STORE;
1414

15-
constructor(
16-
uint32 _oftDstEid,
17-
uint256 _feeCap,
18-
address _adapterStore
19-
) OFTTransportAdapter(_oftDstEid, _feeCap) {
15+
/**
16+
* @notice Initializes the OFTTransportAdapterWithStore contract
17+
* @param _oftDstEid The endpoint ID that OFT protocol will transfer funds to
18+
* @param _feeCap Fee cap checked before sending messages to OFTMessenger
19+
* @param _adapterStore Address of the AdapterStore contract
20+
*/
21+
constructor(uint32 _oftDstEid, uint256 _feeCap, address _adapterStore) OFTTransportAdapter(_oftDstEid, _feeCap) {
2022
OFT_ADAPTER_STORE = AdapterStore(_adapterStore);
2123
}
2224

25+
/**
26+
* @notice Retrieves the OFT messenger address for a given token
27+
* @param _token Token address to look up messenger for
28+
* @return Address of the OFT messenger for the token
29+
*/
2330
function _getOftMessenger(address _token) internal view returns (address) {
2431
return OFT_ADAPTER_STORE.crossChainMessengers(MessengerTypes.OFT_MESSENGER, OFT_DST_EID, _token);
2532
}

0 commit comments

Comments
 (0)