Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FlyoverDiscovery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
address providerAddress,
uint256 collateralAmount
) private view {
if (providerAddress != msg.sender || providerAddress.code.length != 0) revert NotEOA(providerAddress);
if (providerAddress != msg.sender || msg.sender != tx.origin) revert NotEOA(providerAddress);

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

Check warning on line 207 in src/FlyoverDiscovery.sol

View workflow job for this annotation

GitHub Actions / build

Avoid to use tx.origin

if (
bytes(name).length < 1 ||
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/IFlyoverDiscovery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ interface IFlyoverDiscovery is IPausable {
error InsufficientCollateral(uint amount);

/// @notice Registers the caller as a Liquidity Provider
/// @dev Reverts if caller is not an EOA, already resigned, provides invalid data, invalid type, or lacks collateral
/// @dev Reverts if caller is not an EOA, already resigned, provides invalid data,
/// invalid type, or lacks collateral
/// @param name Human-readable LP name
/// @param apiBaseUrl Base URL of the LP public API
/// @param status Initial status flag (enabled/disabled)
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/SignatureValidator.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

library SignatureValidator {

using ECDSA for bytes32;

error IncorrectSignature(address expectedAddress, bytes32 usedHash, bytes signature);
error SignatureCheckError(uint8 errorType, bytes32 errorArg);
error ZeroAddress();
Expand Down Expand Up @@ -34,4 +33,5 @@ library SignatureValidator {
}
return recovered == addr;
}

}
39 changes: 39 additions & 0 deletions test/discovery/NotEoa.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract NotEoaTest is DiscoveryTestBase {

function test_Register_RevertsWhenContractCallsRegister() public {
RegisterCaller caller = new RegisterCaller();
vm.deal(address(caller), 100 ether);

vm.expectRevert(
abi.encodeWithSelector(
Expand All @@ -30,4 +31,42 @@ contract NotEoaTest is DiscoveryTestBase {
Flyover.ProviderType.PegIn
);
}

function test_Register_RevertsWhenContractCallsRegisterWithLowCollateral()
public
{
RegisterCaller caller = new RegisterCaller();
vm.deal(address(caller), 100 ether);

vm.expectRevert(
abi.encodeWithSelector(
IFlyoverDiscovery.NotEOA.selector,
address(caller)
)
);
caller.callRegister{value: MIN_COLLATERAL - 1}(
address(discovery),
"N",
"U",
true,
Flyover.ProviderType.PegIn
);
}

function test_Register_RevertsWhenMsgSenderDiffersFromTxOrigin() public {
address sender = makeAddr("sender");
address origin = makeAddr("origin");
vm.deal(sender, 100 ether);

vm.prank(sender, origin);
vm.expectRevert(
abi.encodeWithSelector(IFlyoverDiscovery.NotEOA.selector, sender)
);
discovery.register{value: MIN_COLLATERAL}(
"N",
"U",
true,
Flyover.ProviderType.PegIn
);
}
}
Loading