@@ -57,7 +57,7 @@ library Messages {
57
57
fill.sourceChain,
58
58
fill.orderSender,
59
59
fill.redeemer,
60
- _encodeBytes (fill.redeemerMessage)
60
+ _encodeRedeemerMessage (fill.redeemerMessage)
61
61
);
62
62
}
63
63
@@ -67,7 +67,7 @@ library Messages {
67
67
(fill.sourceChain, offset) = encoded.asUint16Unchecked (offset);
68
68
(fill.orderSender, offset) = encoded.asBytes32Unchecked (offset);
69
69
(fill.redeemer, offset) = encoded.asBytes32Unchecked (offset);
70
- (fill.redeemerMessage, offset) = _decodeBytes (encoded, offset);
70
+ (fill.redeemerMessage, offset) = _decodeRedeemerMessage (encoded, offset);
71
71
72
72
_checkLength (encoded, offset);
73
73
}
@@ -84,7 +84,7 @@ library Messages {
84
84
order.maxFee,
85
85
order.initAuctionFee,
86
86
order.deadline,
87
- _encodeBytes (order.redeemerMessage)
87
+ _encodeRedeemerMessage (order.redeemerMessage)
88
88
);
89
89
}
90
90
@@ -105,7 +105,7 @@ library Messages {
105
105
(order.maxFee, offset) = encoded.asUint64Unchecked (offset);
106
106
(order.initAuctionFee, offset) = encoded.asUint64Unchecked (offset);
107
107
(order.deadline, offset) = encoded.asUint32Unchecked (offset);
108
- (order.redeemerMessage, offset) = _decodeBytes (encoded, offset);
108
+ (order.redeemerMessage, offset) = _decodeRedeemerMessage (encoded, offset);
109
109
110
110
_checkLength (encoded, offset);
111
111
}
@@ -117,7 +117,7 @@ library Messages {
117
117
fastFill.fill.sourceChain,
118
118
fastFill.fill.orderSender,
119
119
fastFill.fill.redeemer,
120
- _encodeBytes (fastFill.fill.redeemerMessage)
120
+ _encodeRedeemerMessage (fastFill.fill.redeemerMessage)
121
121
);
122
122
}
123
123
@@ -133,7 +133,7 @@ library Messages {
133
133
(fastFill.fill.sourceChain, offset) = encoded.asUint16Unchecked (offset);
134
134
(fastFill.fill.orderSender, offset) = encoded.asBytes32Unchecked (offset);
135
135
(fastFill.fill.redeemer, offset) = encoded.asBytes32Unchecked (offset);
136
- (fastFill.fill.redeemerMessage, offset) = _decodeBytes (encoded, offset);
136
+ (fastFill.fill.redeemerMessage, offset) = _decodeRedeemerMessage (encoded, offset);
137
137
138
138
_checkLength (encoded, offset);
139
139
}
@@ -161,20 +161,22 @@ library Messages {
161
161
162
162
// ---------------------------------------- private -------------------------------------------
163
163
164
- function _decodeBytes (bytes memory encoded , uint256 startOffset )
164
+ function _decodeRedeemerMessage (bytes memory encoded , uint256 startOffset )
165
165
private
166
166
pure
167
167
returns (bytes memory payload , uint256 offset )
168
168
{
169
- uint32 payloadLength;
170
- (payloadLength, offset) = encoded.asUint32Unchecked (startOffset);
169
+ uint16 payloadLength;
170
+ (payloadLength, offset) = encoded.asUint16Unchecked (startOffset);
171
171
(payload, offset) = encoded.sliceUnchecked (offset, payloadLength);
172
172
}
173
173
174
- function _encodeBytes (bytes memory payload ) private pure returns (bytes memory encoded ) {
175
- // Casting payload.length to uint32 is safe because you'll be hard-pressed
176
- // to allocate 4 GB of EVM memory in a single transaction.
177
- encoded = abi.encodePacked (uint32 (payload.length ), payload);
174
+ function _encodeRedeemerMessage (bytes memory payload )
175
+ private
176
+ pure
177
+ returns (bytes memory encoded )
178
+ {
179
+ encoded = abi.encodePacked (uint16 (payload.length ), payload);
178
180
}
179
181
180
182
function _checkLength (bytes memory encoded , uint256 expected ) private pure {
0 commit comments