forked from 1inch/solidity-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Natspec
- Loading branch information
Showing
1 changed file
with
16 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
/** | ||
* @title EthReceiver | ||
* @dev A contract that can receive Ether deposits and reject them if they were not sent from a contract account | ||
*/ | ||
|
||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
abstract contract EthReceiver { | ||
|
||
/** | ||
* @dev Emitted when a deposit is rejected because it was not sent from a contract account | ||
*/ | ||
error EthDepositRejected(); | ||
|
||
|
||
/** | ||
* @dev Fallback function that is called when a contract receives Ether | ||
*/ | ||
receive() external payable { | ||
_receive(); | ||
} | ||
|
||
/** | ||
* @dev Internal function to receive Ether deposits and reject them if they were not sent from a contract account | ||
*/ | ||
function _receive() internal virtual { | ||
// solhint-disable-next-line avoid-tx-origin | ||
if (msg.sender == tx.origin) revert EthDepositRejected(); | ||
} | ||
} |