@@ -8,7 +8,15 @@ library EndpointStructs {
8
8
using BytesParsing for bytes ;
9
9
using NormalizedAmountLib for NormalizedAmount;
10
10
11
+ /// @notice Error thrown when the payload length exceeds the allowed maximum.
12
+ /// @dev Selector 0xa3419691.
13
+ /// @param size The size of the payload.
11
14
error PayloadTooLong (uint256 size );
15
+
16
+ /// @notice Error thrown when the prefix of an encoded message
17
+ /// does not match the expected value.
18
+ /// @dev Selector 0x56d2569d.
19
+ /// @param prefix The prefix that was found in the encoded message.
12
20
error IncorrectPrefix (bytes4 prefix );
13
21
error UnorderedInstructions ();
14
22
@@ -50,11 +58,9 @@ library EndpointStructs {
50
58
return abi.encodePacked (m.sequence, m.sender, payloadLength, m.payload);
51
59
}
52
60
53
- /*
54
- * @dev Parse a ManagerMessage.
55
- *
56
- * @params encoded The byte array corresponding to the encoded message
57
- */
61
+ /// @notice Parse a ManagerMessage.
62
+ /// @param encoded The byte array corresponding to the encoded message
63
+ /// @return managerMessage The parsed ManagerMessage struct.
58
64
function parseManagerMessage (bytes memory encoded )
59
65
public
60
66
pure
@@ -104,11 +110,9 @@ library EndpointStructs {
104
110
);
105
111
}
106
112
107
- /*
108
- * @dev Parse a NativeTokenTransfer.
109
- *
110
- * @params encoded The byte array corresponding to the encoded message
111
- */
113
+ /// @dev Parse a NativeTokenTransfer.
114
+ /// @param encoded The byte array corresponding to the encoded message
115
+ /// @return nativeTokenTransfer The parsed NativeTokenTransfer struct.
112
116
function parseNativeTokenTransfer (bytes memory encoded )
113
117
public
114
118
pure
@@ -154,13 +158,12 @@ library EndpointStructs {
154
158
bytes endpointPayload;
155
159
}
156
160
157
- /*
158
- * @dev Encodes an Endpoint message for communication between the Manager and the Endpoint.
159
- *
160
- * @param m The EndpointMessage struct containing the message details.
161
- * @return encoded The byte array corresponding to the encoded message.
162
- * @throws PayloadTooLong if the length of endpointId, managerPayload, or endpointPayload exceeds the allowed maximum.
163
- */
161
+ // @notice Encodes an Endpoint message for communication between the
162
+ // Manager and the Endpoint.
163
+ // @param m The EndpointMessage struct containing the message details.
164
+ // @return encoded The byte array corresponding to the encoded message.
165
+ // @custom:throw PayloadTooLong if the length of endpointId, managerPayload,
166
+ // or endpointPayload exceeds the allowed maximum.
164
167
function encodeEndpointMessage (
165
168
bytes4 prefix ,
166
169
EndpointMessage memory m
@@ -203,13 +206,11 @@ library EndpointStructs {
203
206
return (endpointMessage, encoded);
204
207
}
205
208
206
- /*
207
- * @dev Parses an encoded message and extracts information into an EndpointMessage struct.
208
- *
209
- * @param encoded The encoded bytes containing information about the EndpointMessage.
210
- * @return endpointMessage The parsed EndpointMessage struct.
211
- * @throws IncorrectPrefix if the prefix of the encoded message does not match the expected prefix.
212
- */
209
+ /// @dev Parses an encoded message and extracts information into an EndpointMessage struct.
210
+ /// @param encoded The encoded bytes containing information about the EndpointMessage.
211
+ /// @return endpointMessage The parsed EndpointMessage struct.
212
+ /// @custom:throw IncorrectPrefix if the prefix of the encoded message does not
213
+ /// match the expected prefix.
213
214
function parseEndpointMessage (
214
215
bytes4 expectedPrefix ,
215
216
bytes memory encoded
@@ -238,7 +239,10 @@ library EndpointStructs {
238
239
encoded.checkLength (offset);
239
240
}
240
241
241
- /// @dev Parses the payload of an Endpoint message and returns the parsed ManagerMessage struct.
242
+ /// @dev Parses the payload of an Endpoint message and returns
243
+ /// the parsed ManagerMessage struct.
244
+ /// @param expectedPrefix The prefix that should be encoded in the manager message.
245
+ /// @param payload The payload sent across the wire.
242
246
function parseEndpointAndManagerMessage (
243
247
bytes4 expectedPrefix ,
244
248
bytes memory payload
0 commit comments