Skip to content

Commit

Permalink
Update EthReceiver.sol
Browse files Browse the repository at this point in the history
Added Natspec
  • Loading branch information
zodenode authored May 7, 2023
1 parent b51b934 commit 7fb78be
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions contracts/EthReceiver.sol
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();
}
}

0 comments on commit 7fb78be

Please sign in to comment.