Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natspec improvements in MagicSpend.sol #19

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Changes from 2 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
27 changes: 15 additions & 12 deletions src/MagicSpend.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract MagicSpend is Ownable, IPaymaster {

/// @notice Thrown when trying to replay a withdraw request with the same nonce.
///
/// @param nonce The already used nonce.
/// @param nonce The nonce being replayed.
wilsoncusack marked this conversation as resolved.
Show resolved Hide resolved
wilsoncusack marked this conversation as resolved.
Show resolved Hide resolved
error InvalidNonce(uint256 nonce);

/// @notice Thrown during validation in the context of ERC4337, when the withdraw request amount is insufficient
Expand All @@ -78,7 +78,7 @@ contract MagicSpend is Ownable, IPaymaster {
/// @param maxCost The max gas cost required by the Entrypoint.
error RequestLessThanGasMaxCost(uint256 requested, uint256 maxCost);

/// @notice Thrown when the withdraw request asset is not ETH (zero address).
/// @notice Thrown when the withdraw request `asset` is not ETH (zero address).
///
/// @param asset The requested asset.
error UnsupportedPaymasterAsset(address asset);
Expand All @@ -92,9 +92,9 @@ contract MagicSpend is Ownable, IPaymaster {
/// @notice Thrown when trying to withdraw funds but nothing is available.
error NoExcess();

/// @notice Thrown in when `postOp()` is called a second time with `PostOpMode.postOpReverted`.
/// @notice Thrown when `postOp()` is called a second time with `PostOpMode.postOpReverted`.
///
/// @dev This should only really occur if for unknown reasons the transfer of the withdrawable
/// @dev This should only really occur if, for unknown reasons, the transfer of the withdrawable
/// funds to the user account failed (i.e. this contract's ETH balance is insufficient or
/// the user account refused the funds or ran out of gas on receive).
error UnexpectedPostOpRevertedMode();
Expand Down Expand Up @@ -171,7 +171,7 @@ contract MagicSpend is Ownable, IPaymaster {
}
}

/// @notice Allows the sender to withdraw any available funds associated with him.
/// @notice Allows the sender to withdraw any available funds associated with their account.
///
/// @dev Can be called back during the `UserOperation` execution to sponsor funds for non-gas related
/// use cases (e.g., swap or mint).
Expand All @@ -184,7 +184,7 @@ contract MagicSpend is Ownable, IPaymaster {
_withdraw(address(0), msg.sender, amount);
}

/// @notice Allows caller to withdraw funds by calling with a valid `withdrawRequest`
/// @notice Allows the caller to withdraw funds by calling with a valid `withdrawRequest`.
///
/// @param withdrawRequest The withdraw request.
function withdraw(WithdrawRequest memory withdrawRequest) external {
Expand All @@ -206,14 +206,14 @@ contract MagicSpend is Ownable, IPaymaster {
///
/// @dev Reverts if not called by the owner of the contract.
///
/// @param asset The asset to withdraw.
/// @param to The beneficiary address.
/// @param asset The asset to withdraw.
/// @param to The beneficiary address.
/// @param amount The amount to withdraw.
function ownerWithdraw(address asset, address to, uint256 amount) external onlyOwner {
_withdraw(asset, to, amount);
}

/// @notice Deposits ETH from this contract funds into the EntryPoint.
/// @notice Transfers ETH from this contract into the EntryPoint.
///
/// @dev Reverts if not called by the owner of the contract.
///
Expand All @@ -234,10 +234,12 @@ contract MagicSpend is Ownable, IPaymaster {

/// @notice Adds stake to the EntryPoint.
///
/// @dev Reverts if not called by the owner of the contract.
/// @dev Reverts if not called by the owner of the contract. Calling this while an unstake
/// is pending will first cancel the pending unstake.
///
/// @param amount The amount to stake in the Entrypoint.
/// @param unstakeDelaySeconds The duration for which the stake cannot be withdrawn.
/// @param unstakeDelaySeconds The duration for which the stake cannot be withdrawn. Must be
/// equal to or greater than the current unstake delay.
function entryPointAddStake(uint256 amount, uint32 unstakeDelaySeconds) external payable onlyOwner {
IEntryPoint(entryPoint()).addStake{value: amount}(unstakeDelaySeconds);
}
Expand All @@ -251,7 +253,8 @@ contract MagicSpend is Ownable, IPaymaster {

/// @notice Withdraws stake from the EntryPoint.
///
/// @dev Reverts if not called by the owner of the contract.
/// @dev Reverts if not called by the owner of the contract. Only call this after the unstake delay
/// has passed since the last `entryPointUnlockStake` call.
///
/// @param to The beneficiary address.
function entryPointWithdrawStake(address payable to) external onlyOwner {
Expand Down
Loading