Skip to content

Commit

Permalink
style(ctp): clean up Drippie natspec (#2994)
Browse files Browse the repository at this point in the history
Cleans up natspec for Drippie and its dependencies.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
smartcontracts and mergify[bot] committed Jul 12, 2022
1 parent 119f0e9 commit 6ff5c0a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 51 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-trees-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/contracts-periphery': patch
---

Cleaned up natspec for Drippie and its dependencies
48 changes: 32 additions & 16 deletions packages/contracts-periphery/contracts/universal/AssetReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,28 @@ import { Transactor } from "./Transactor.sol";
*/
contract AssetReceiver is Transactor {
/**
* Emitted when ETH is received by this address.
* @notice Emitted when ETH is received by this address.
*
* @param from Address that sent ETH to this contract.
*/
event ReceivedETH(address indexed from, uint256 amount);

/**
* Emitted when ETH is withdrawn from this address.
* @notice Emitted when ETH is withdrawn from this address.
*
* @param withdrawer Address that triggered the withdrawal.
* @param recipient Address that received the withdrawal.
* @param amount ETH amount withdrawn.
*/
event WithdrewETH(address indexed withdrawer, address indexed recipient, uint256 amount);

/**
* Emitted when ERC20 tokens are withdrawn from this address.
* @notice Emitted when ERC20 tokens are withdrawn from this address.
*
* @param withdrawer Address that triggered the withdrawal.
* @param recipient Address that received the withdrawal.
* @param asset Address of the token being withdrawn.
* @param amount ERC20 amount withdrawn.
*/
event WithdrewERC20(
address indexed withdrawer,
Expand All @@ -32,7 +43,12 @@ contract AssetReceiver is Transactor {
);

/**
* Emitted when ERC721 tokens are withdrawn from this address.
* @notice Emitted when ERC20 tokens are withdrawn from this address.
*
* @param withdrawer Address that triggered the withdrawal.
* @param recipient Address that received the withdrawal.
* @param asset Address of the token being withdrawn.
* @param id Token ID being withdrawn.
*/
event WithdrewERC721(
address indexed withdrawer,
Expand All @@ -47,14 +63,14 @@ contract AssetReceiver is Transactor {
constructor(address _owner) Transactor(_owner) {}

/**
* Make sure we can receive ETH.
* @notice Make sure we can receive ETH.
*/
receive() external payable {
emit ReceivedETH(msg.sender, msg.value);
}

/**
* Withdraws full ETH balance to the recipient.
* @notice Withdraws full ETH balance to the recipient.
*
* @param _to Address to receive the ETH balance.
*/
Expand All @@ -63,9 +79,9 @@ contract AssetReceiver is Transactor {
}

/**
* Withdraws partial ETH balance to the recipient.
* @notice Withdraws partial ETH balance to the recipient.
*
* @param _to Address to receive the ETH balance.
* @param _to Address to receive the ETH balance.
* @param _amount Amount of ETH to withdraw.
*/
function withdrawETH(address payable _to, uint256 _amount) public onlyOwner {
Expand All @@ -75,20 +91,20 @@ contract AssetReceiver is Transactor {
}

/**
* Withdraws full ERC20 balance to the recipient.
* @notice Withdraws full ERC20 balance to the recipient.
*
* @param _asset ERC20 token to withdraw.
* @param _to Address to receive the ERC20 balance.
* @param _to Address to receive the ERC20 balance.
*/
function withdrawERC20(ERC20 _asset, address _to) external onlyOwner {
withdrawERC20(_asset, _to, _asset.balanceOf(address(this)));
}

/**
* Withdraws partial ERC20 balance to the recipient.
* @notice Withdraws partial ERC20 balance to the recipient.
*
* @param _asset ERC20 token to withdraw.
* @param _to Address to receive the ERC20 balance.
* @param _asset ERC20 token to withdraw.
* @param _to Address to receive the ERC20 balance.
* @param _amount Amount of ERC20 to withdraw.
*/
function withdrawERC20(
Expand All @@ -103,11 +119,11 @@ contract AssetReceiver is Transactor {
}

/**
* Withdraws ERC721 token to the recipient.
* @notice Withdraws ERC721 token to the recipient.
*
* @param _asset ERC721 token to withdraw.
* @param _to Address to receive the ERC721 token.
* @param _id Token ID of the ERC721 token to withdraw.
* @param _to Address to receive the ERC721 token.
* @param _id Token ID of the ERC721 token to withdraw.
*/
function withdrawERC721(
ERC721 _asset,
Expand Down
12 changes: 7 additions & 5 deletions packages/contracts-periphery/contracts/universal/Transactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ contract Transactor is Owned {
* Sends a CALL to a target address.
*
* @param _target Address to call.
* @param _data Data to send with the call.
* @param _gas Amount of gas to send with the call.
* @param _value ETH value to send with the call.
* @param _data Data to send with the call.
* @param _gas Amount of gas to send with the call.
* @param _value ETH value to send with the call.
*
* @return Boolean success value.
* @return Bytes data returned by the call.
*/
Expand All @@ -36,8 +37,9 @@ contract Transactor is Owned {
* Sends a DELEGATECALL to a target address.
*
* @param _target Address to call.
* @param _data Data to send with the call.
* @param _gas Amount of gas to send with the call.
* @param _data Data to send with the call.
* @param _gas Amount of gas to send with the call.
*
* @return Boolean success value.
* @return Bytes data returned by the call.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ import { IDripCheck } from "./IDripCheck.sol";
/**
* @title Drippie
* @notice Drippie is a system for managing automated contract interactions. A specific interaction
* is called a "drip" and can be executed according to some condition (called a dripcheck) and an
* execution interval. Drips cannot be executed faster than the execution interval. Drips can
* trigger arbitrary contract calls where the calling contract is this contract address. Drips can
* also send ETH value, which makes them ideal for keeping addresses sufficiently funded with ETH.
* Drippie is designed to be connected with smart contract automation services so that drips can be
* executed automatically. However, Drippie is specifically designed to be separated from these
* services so that trust assumptions are better compartmentalized.
* is called a "drip" and can be executed according to some condition (called a dripcheck)
* and an execution interval. Drips cannot be executed faster than the execution interval.
* Drips can trigger arbitrary contract calls where the calling contract is this contract
* address. Drips can also send ETH value, which makes them ideal for keeping addresses
* sufficiently funded with ETH. Drippie is designed to be connected with smart contract
* automation services so that drips can be executed automatically. However, Drippie is
* specifically designed to be separated from these services so that trust assumptions are
* better compartmentalized.
*/
contract Drippie is AssetReceiver {
/**
* Enum representing different status options for a given drip.
* @notice Enum representing different status options for a given drip.
*
* @custom:value NONE Drip does not exist.
* @custom:value ACTIVE Drip is active and can be executed.
* @custom:value PAUSED Drip is paused and cannot be executed until reactivated.
* @custom:value ARCHIVED Drip is archived and can no longer be executed or reactivated.
*/
enum DripStatus {
NONE,
Expand All @@ -27,7 +33,7 @@ contract Drippie is AssetReceiver {
}

/**
* Represents a drip action.
* @notice Represents a drip action.
*/
struct DripAction {
address payable target;
Expand All @@ -36,7 +42,7 @@ contract Drippie is AssetReceiver {
}

/**
* Represents the configuration for a given drip.
* @notice Represents the configuration for a given drip.
*/
struct DripConfig {
uint256 interval;
Expand All @@ -46,7 +52,7 @@ contract Drippie is AssetReceiver {
}

/**
* Represents the state of an active drip.
* @notice Represents the state of an active drip.
*/
struct DripState {
DripStatus status;
Expand All @@ -56,7 +62,11 @@ contract Drippie is AssetReceiver {
}

/**
* Emitted when a new drip is created.
* @notice Emitted when a new drip is created.
*
* @param nameref Indexed name parameter (hashed).
* @param name Unindexed name parameter (unhashed).
* @param config Config for the created drip.
*/
event DripCreated(
// Emit name twice because indexed version is hashed.
Expand All @@ -66,7 +76,11 @@ contract Drippie is AssetReceiver {
);

/**
* Emitted when a drip status is updated.
* @notice Emitted when a drip status is updated.
*
* @param nameref Indexed name parameter (hashed).
* @param name Unindexed name parameter (unhashed).
* @param status New drip status.
*/
event DripStatusUpdated(
// Emit name twice because indexed version is hashed.
Expand All @@ -76,7 +90,12 @@ contract Drippie is AssetReceiver {
);

/**
* Emitted when a drip is executed.
* @notice Emitted when a drip is executed.
*
* @param nameref Indexed name parameter (hashed).
* @param name Unindexed name parameter (unhashed).
* @param executor Address that executed the drip.
* @param timestamp Time when the drip was executed.
*/
event DripExecuted(
// Emit name twice because indexed version is hashed.
Expand All @@ -87,7 +106,7 @@ contract Drippie is AssetReceiver {
);

/**
* Maps from drip names to drip states.
* @notice Maps from drip names to drip states.
*/
mapping(string => DripState) public drips;

Expand All @@ -97,11 +116,11 @@ contract Drippie is AssetReceiver {
constructor(address _owner) AssetReceiver(_owner) {}

/**
* Creates a new drip with the given name and configuration. Once created, drips cannot be
* modified in any way (this is a security measure). If you want to update a drip, simply pause
* (and potentially archive) the existing drip and create a new one.
* @notice Creates a new drip with the given name and configuration. Once created, drips cannot
* be modified in any way (this is a security measure). If you want to update a drip,
* simply pause (and potentially archive) the existing drip and create a new one.
*
* @param _name Name of the drip.
* @param _name Name of the drip.
* @param _config Configuration for the drip.
*/
function create(string memory _name, DripConfig memory _config) external onlyOwner {
Expand Down Expand Up @@ -130,11 +149,12 @@ contract Drippie is AssetReceiver {
}

/**
* Sets the status for a given drip. The behavior of this function depends on the status that
* the user is trying to set. A drip can always move between ACTIVE and PAUSED, but it can
* never move back to NONE and once ARCHIVED, it can never move back to ACTIVE or PAUSED.
* @notice Sets the status for a given drip. The behavior of this function depends on the
* status that the user is trying to set. A drip can always move between ACTIVE and
* PAUSED, but it can never move back to NONE and once ARCHIVED, it can never move back
* to ACTIVE or PAUSED.
*
* @param _name Name of the drip to update.
* @param _name Name of the drip to update.
* @param _status New drip status.
*/
function status(string memory _name, DripStatus _status) external onlyOwner {
Expand Down Expand Up @@ -184,9 +204,10 @@ contract Drippie is AssetReceiver {
}

/**
* Checks if a given drip is executable.
* @notice Checks if a given drip is executable.
*
* @param _name Drip to check.
*
* @return True if the drip is executable, false otherwise.
*/
function executable(string memory _name) public view returns (bool) {
Expand Down Expand Up @@ -219,12 +240,12 @@ contract Drippie is AssetReceiver {
}

/**
* Triggers a drip. This function is deliberately left as a public function because the
* assumption being made here is that setting the drip to ACTIVE is an affirmative signal that
* the drip should be executable according to the drip parameters, drip check, and drip
* interval. Note that drip parameters are read entirely from the state and are not supplied as
* user input, so there should not be any way for a non-authorized user to influence the
* behavior of the drip.
* @notice Triggers a drip. This function is deliberately left as a public function because the
* assumption being made here is that setting the drip to ACTIVE is an affirmative
* signal that the drip should be executable according to the drip parameters, drip
* check, and drip interval. Note that drip parameters are read entirely from the state
* and are not supplied as user input, so there should not be any way for a
* non-authorized user to influence the behavior of the drip.
*
* @param _name Name of the drip to trigger.
*/
Expand Down

0 comments on commit 6ff5c0a

Please sign in to comment.