Skip to content

Commit

Permalink
prevent empty non-evm addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 committed Nov 26, 2024
1 parent 4b3535f commit f285130
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Facets/RelayFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ contract RelayFacet is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
revert InvalidQuote();
}

// Ensure nonEVMAddress is not empty
if (
_bridgeData.receiver == LibAsset.NON_EVM_ADDRESS &&
_relayData.nonEVMReceiver == bytes32(0)
) {
revert InvalidQuote();
}

// Verify that the bridging quote has been signed by the Relay solver
// as attested using the attestation API
// API URL: https://api.relay.link/requests/{requestId}/signature/v2
Expand Down
24 changes: 24 additions & 0 deletions test/solidity/Facets/RelayFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,30 @@ contract RelayFacetTest is TestBaseFacet {
vm.stopPrank();
}

function testRevert_WhenUsingEmptyNonEVMAddress() public virtual {
bridgeData.receiver = LibAsset.NON_EVM_ADDRESS;
bridgeData.destinationChainId = 1151111081099710;
validRelayData = RelayFacet.RelayData({
requestId: bytes32("1234"),
nonEVMReceiver: bytes32(0), // DEV Wallet
receivingAssetId: bytes32(
abi.encodePacked(
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
)
), // Solana USDC
signature: ""
});

vm.startPrank(USER_SENDER);

// approval
usdc.approve(_facetTestContractAddress, bridgeData.minAmount);

vm.expectRevert(InvalidQuote.selector);
initiateBridgeTxWithFacet(false);
vm.stopPrank();
}

function testRevert_WhenReplayingTransactionIds() public virtual {
relayFacet.setConsumedId(validRelayData.requestId);
bridgeData.receiver = LibAsset.NON_EVM_ADDRESS;
Expand Down

0 comments on commit f285130

Please sign in to comment.