Skip to content

Commit

Permalink
rearrange refund validation checks [SLT-185]
Browse files Browse the repository at this point in the history
  • Loading branch information
parodime committed Sep 23, 2024
1 parent faf9387 commit b9f2ed5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ contract FastBridgeV2 is Admin, IFastBridgeV2 {
/// @inheritdoc IFastBridge
function refund(bytes memory request) external {
bytes32 transactionId = keccak256(request);

if (bridgeStatuses[transactionId] != BridgeStatus.REQUESTED) revert StatusIncorrect();

BridgeTransaction memory transaction = getBridgeTransaction(request);

if (hasRole(REFUNDER_ROLE, msg.sender)) {
Expand All @@ -272,8 +275,7 @@ contract FastBridgeV2 is Admin, IFastBridgeV2 {
if (block.timestamp <= transaction.deadline + REFUND_DELAY) revert DeadlineNotExceeded();
}

// set status to refunded if still in requested state
if (bridgeStatuses[transactionId] != BridgeStatus.REQUESTED) revert StatusIncorrect();
// if all checks passed, set to REFUNDED status
bridgeStatuses[transactionId] = BridgeStatus.REFUNDED;

// transfer origin collateral back to original sender
Expand Down
3 changes: 0 additions & 3 deletions packages/contracts-rfq/test/FastBridgeV2.Src.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -800,21 +800,18 @@ contract FastBridgeV2SrcTest is FastBridgeV2Test {
}

function test_refund_revert_statusNull() public {
vm.skip(true); // TODO: unskip when fixed
vm.expectRevert(StatusIncorrect.selector);
refund({caller: refunder, bridgeTx: ethTx});
}

function test_refund_revert_statusProven() public {
vm.skip(true); // TODO: unskip when fixed
bridge({caller: userA, msgValue: 0, params: tokenParams});
prove({caller: relayerA, bridgeTx: tokenTx, destTxHash: hex"01"});
vm.expectRevert(StatusIncorrect.selector);
refund({caller: refunder, bridgeTx: tokenTx});
}

function test_refund_revert_statusClaimed() public {
vm.skip(true); // TODO: unskip when fixed
bridge({caller: userA, msgValue: 0, params: tokenParams});
prove({caller: relayerA, bridgeTx: tokenTx, destTxHash: hex"01"});
skip(CLAIM_DELAY + 1);
Expand Down

0 comments on commit b9f2ed5

Please sign in to comment.