Skip to content

Commit 9be950e

Browse files
committed
address some review comments from @nambrot
1 parent e05b42b commit 9be950e

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

solidity/src/Base7683.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ abstract contract Base7683 is IOriginSettler, IDestinationSettler {
244244
* @dev Pays the filler the amount locked when the orders were opened.
245245
* The settled status should not be changed here but rather on the origin chain. To allow the filler to retry in
246246
* case some error occurs.
247-
* Ensuring the order is not settled in the origin chain is the responsibility of the caller.
247+
* Ensuring the order is eligible for settling in the origin chain is the responsibility of the caller.
248248
* @param _orderIds An array of IDs for the orders to settle.
249249
*/
250250
function settle(bytes32[] calldata _orderIds) external payable {
@@ -267,7 +267,7 @@ abstract contract Base7683 is IOriginSettler, IDestinationSettler {
267267
* @notice Refunds a batch of expired GaslessCrossChainOrders on the chain where the orders were opened.
268268
* The refunded status should not be changed here but rather on the origin chain. To allow the user to retry in
269269
* case some error occurs.
270-
* Ensuring the order is not refunded in the origin chain is the responsibility of the caller.
270+
* Ensuring the order is eligible for refunding in the origin chain is the responsibility of the caller.
271271
* @param _orders An array of GaslessCrossChainOrders to refund.
272272
*/
273273
function refund(GaslessCrossChainOrder[] memory _orders) external payable {
@@ -289,7 +289,7 @@ abstract contract Base7683 is IOriginSettler, IDestinationSettler {
289289
* @notice Refunds a batch of expired OnchainCrossChainOrder on the chain where the orders were opened.
290290
* The refunded status should not be changed here but rather on the origin chain. To allow the user to retry in
291291
* case some error occurs.
292-
* Ensuring the order is not refunded in the origin chain is the responsibility of the caller.
292+
* Ensuring the order is eligible for refunding the origin chain is the responsibility of the caller.
293293
* @param _orders An array of GaslessCrossChainOrders to refund.
294294
*/
295295
function refund(OnchainCrossChainOrder[] memory _orders) external payable {

solidity/src/BasicSwap7683.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ abstract contract BasicSwap7683 is Base7683 {
109109
*/
110110
function _refundOrders(OnchainCrossChainOrder[] memory _orders, bytes32[] memory _orderIds) internal override {
111111
// at this point we are sure all orders are NOT filled, use the first order to get the originDomain
112-
// if some order differs on the originDomain ir can be re-refunded later
112+
// if some order differs on the originDomain it can be re-refunded later
113113
_dispatchRefund(OrderEncoder.decode(_orders[0].orderData).originDomain, _orderIds);
114114
}
115115

@@ -139,11 +139,11 @@ abstract contract BasicSwap7683 is Base7683 {
139139
bytes32 _receiver
140140
) internal virtual {
141141
(
142-
bool validOpenOrder,
142+
bool isEligible,
143143
OrderData memory orderData
144-
) = _isValidOpenOrder(_messageOrigin, _messageSender, _orderId);
144+
) = _checkOrderEligibility(_messageOrigin, _messageSender, _orderId);
145145

146-
if (!validOpenOrder) return;
146+
if (!isEligible) return;
147147

148148
orderStatus[_orderId] = SETTLED;
149149

@@ -164,11 +164,11 @@ abstract contract BasicSwap7683 is Base7683 {
164164
*/
165165
function _handleRefundOrder(uint32 _messageOrigin, bytes32 _messageSender, bytes32 _orderId) internal virtual {
166166
(
167-
bool validOpenOrder,
167+
bool isEligible,
168168
OrderData memory orderData
169-
) = _isValidOpenOrder(_messageOrigin, _messageSender, _orderId);
169+
) = _checkOrderEligibility(_messageOrigin, _messageSender, _orderId);
170170

171-
if (!validOpenOrder) return;
171+
if (!isEligible) return;
172172

173173
orderStatus[_orderId] = REFUNDED;
174174

@@ -181,14 +181,14 @@ abstract contract BasicSwap7683 is Base7683 {
181181
}
182182

183183
/**
184-
* @notice Validates an open order.
185-
* @dev Checks that the order is open and that its destination domain and settler match the provided parameters.
184+
* @notice Checks if order is eligible for settlement or refund .
185+
* @dev Order must be OPENED and the message was sent from the appropriated chain and contract.
186186
* @param _messageOrigin The origin domain of the message.
187187
* @param _messageSender The sender identifier of the message.
188188
* @param _orderId The unique identifier of the order.
189189
* @return A boolean indicating if the order is valid, and the decoded OrderData structure.
190190
*/
191-
function _isValidOpenOrder(
191+
function _checkOrderEligibility(
192192
uint32 _messageOrigin,
193193
bytes32 _messageSender,
194194
bytes32 _orderId

solidity/test/BasicSwap7683.t.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ contract BasicSwap7683Test is BaseTest {
159159

160160
BasicSwap7683ForTest internal baseSwap;
161161

162+
uint32 internal wrongMssgOrigin = 678;
163+
bytes32 internal wrongMssgSender = makeAddr("wrongMssgSender").addressToBytes32();
164+
162165
function setUp() public override {
163166
super.setUp();
164167

@@ -372,7 +375,7 @@ contract BasicSwap7683Test is BaseTest {
372375
uint256[] memory balancesBefore = _balances(inputToken);
373376

374377
baseSwap.handleSettleOrder(
375-
678,
378+
wrongMssgOrigin,
376379
counterpart.addressToBytes32(),
377380
orderId,
378381
TypeCasts.addressToBytes32(karpincho)
@@ -395,7 +398,7 @@ contract BasicSwap7683Test is BaseTest {
395398

396399
baseSwap.handleSettleOrder(
397400
destination,
398-
makeAddr("wrongMssgSender").addressToBytes32(),
401+
wrongMssgSender,
399402
orderId,
400403
TypeCasts.addressToBytes32(karpincho)
401404
);
@@ -495,7 +498,7 @@ contract BasicSwap7683Test is BaseTest {
495498
uint256[] memory balancesBefore = _balances(inputToken);
496499

497500
baseSwap.handleRefundOrder(
498-
678,
501+
wrongMssgOrigin,
499502
counterpart.addressToBytes32(),
500503
orderId
501504
);
@@ -518,7 +521,7 @@ contract BasicSwap7683Test is BaseTest {
518521

519522
baseSwap.handleRefundOrder(
520523
destination,
521-
makeAddr("wrongMssgSender").addressToBytes32(),
524+
wrongMssgSender,
522525
orderId
523526
);
524527

0 commit comments

Comments
 (0)