Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e175fd8f
Commit
e175fd8f
authored
Jul 20, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port periphery contracts to triple slash natspec styling
parent
8cf3f96f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
101 deletions
+56
-101
AssetReceiver.sol
...s/contracts-bedrock/contracts/periphery/AssetReceiver.sol
+38
-71
Transactor.sol
...ages/contracts-bedrock/contracts/periphery/Transactor.sol
+18
-30
No files found.
packages/contracts-bedrock/contracts/periphery/AssetReceiver.sol
View file @
e175fd8f
...
@@ -5,37 +5,26 @@ import { ERC20 } from "@rari-capital/solmate/src/tokens/ERC20.sol";
...
@@ -5,37 +5,26 @@ import { ERC20 } from "@rari-capital/solmate/src/tokens/ERC20.sol";
import { ERC721 } from "@rari-capital/solmate/src/tokens/ERC721.sol";
import { ERC721 } from "@rari-capital/solmate/src/tokens/ERC721.sol";
import { Transactor } from "./Transactor.sol";
import { Transactor } from "./Transactor.sol";
/**
/// @title AssetReceiver
* @title AssetReceiver
/// @notice AssetReceiver is a minimal contract for receiving funds assets in the form of either
* @notice AssetReceiver is a minimal contract for receiving funds assets in the form of either
/// ETH, ERC20 tokens, or ERC721 tokens. Only the contract owner may withdraw the assets.
* ETH, ERC20 tokens, or ERC721 tokens. Only the contract owner may withdraw the assets.
*/
contract AssetReceiver is Transactor {
contract AssetReceiver is Transactor {
/**
/// @notice 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.
*
/// @param amount Amount of ETH received.
* @param from Address that sent ETH to this contract.
* @param amount Amount of ETH received.
*/
event ReceivedETH(address indexed from, uint256 amount);
event ReceivedETH(address indexed from, uint256 amount);
/**
/// @notice 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 withdrawer Address that triggered the withdrawal.
/// @param amount ETH amount withdrawn.
* @param recipient Address that received the withdrawal.
* @param amount ETH amount withdrawn.
*/
event WithdrewETH(address indexed withdrawer, address indexed recipient, uint256 amount);
event WithdrewETH(address indexed withdrawer, address indexed recipient, uint256 amount);
/**
/// @notice 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 withdrawer Address that triggered the withdrawal.
/// @param asset Address of the token being withdrawn.
* @param recipient Address that received the withdrawal.
/// @param amount ERC20 amount withdrawn.
* @param asset Address of the token being withdrawn.
* @param amount ERC20 amount withdrawn.
*/
event WithdrewERC20(
event WithdrewERC20(
address indexed withdrawer,
address indexed withdrawer,
address indexed recipient,
address indexed recipient,
...
@@ -43,14 +32,11 @@ contract AssetReceiver is Transactor {
...
@@ -43,14 +32,11 @@ contract AssetReceiver is Transactor {
uint256 amount
uint256 amount
);
);
/**
/// @notice 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 withdrawer Address that triggered the withdrawal.
/// @param asset Address of the token being withdrawn.
* @param recipient Address that received the withdrawal.
/// @param id Token ID being withdrawn.
* @param asset Address of the token being withdrawn.
* @param id Token ID being withdrawn.
*/
event WithdrewERC721(
event WithdrewERC721(
address indexed withdrawer,
address indexed withdrawer,
address indexed recipient,
address indexed recipient,
...
@@ -58,56 +44,40 @@ contract AssetReceiver is Transactor {
...
@@ -58,56 +44,40 @@ contract AssetReceiver is Transactor {
uint256 id
uint256 id
);
);
/**
/// @param _owner Initial contract owner.
* @param _owner Initial contract owner.
*/
constructor(address _owner) Transactor(_owner) {}
constructor(address _owner) Transactor(_owner) {}
/**
/// @notice Make sure we can receive ETH.
* @notice Make sure we can receive ETH.
*/
receive() external payable {
receive() external payable {
emit ReceivedETH(msg.sender, msg.value);
emit ReceivedETH(msg.sender, msg.value);
}
}
/**
/// @notice Withdraws full ETH balance to the recipient.
* @notice Withdraws full ETH balance to the recipient.
/// @param _to Address to receive the ETH balance.
*
* @param _to Address to receive the ETH balance.
*/
function withdrawETH(address payable _to) external onlyOwner {
function withdrawETH(address payable _to) external onlyOwner {
withdrawETH(_to, address(this).balance);
withdrawETH(_to, address(this).balance);
}
}
/**
/// @notice Withdraws partial ETH balance to the recipient.
* @notice Withdraws partial ETH balance to the recipient.
/// @param _to Address to receive the ETH balance.
*
/// @param _amount Amount of ETH to withdraw.
* @param _to Address to receive the ETH balance.
* @param _amount Amount of ETH to withdraw.
*/
function withdrawETH(address payable _to, uint256 _amount) public onlyOwner {
function withdrawETH(address payable _to, uint256 _amount) public onlyOwner {
// slither-disable-next-line reentrancy-unlimited-gas
// slither-disable-next-line reentrancy-unlimited-gas
(bool success, ) = _to.call{ value: _amount }("");
(bool success, ) = _to.call{ value: _amount }("");
emit WithdrewETH(msg.sender, _to, _amount);
emit WithdrewETH(msg.sender, _to, _amount);
}
}
/**
/// @notice 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 _asset ERC20 token to withdraw.
* @param _to Address to receive the ERC20 balance.
*/
function withdrawERC20(ERC20 _asset, address _to) external onlyOwner {
function withdrawERC20(ERC20 _asset, address _to) external onlyOwner {
withdrawERC20(_asset, _to, _asset.balanceOf(address(this)));
withdrawERC20(_asset, _to, _asset.balanceOf(address(this)));
}
}
/**
/// @notice 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 _amount Amount of ERC20 to withdraw.
* @param _to Address to receive the ERC20 balance.
* @param _amount Amount of ERC20 to withdraw.
*/
function withdrawERC20(
function withdrawERC20(
ERC20 _asset,
ERC20 _asset,
address _to,
address _to,
...
@@ -119,13 +89,10 @@ contract AssetReceiver is Transactor {
...
@@ -119,13 +89,10 @@ contract AssetReceiver is Transactor {
emit WithdrewERC20(msg.sender, _to, address(_asset), _amount);
emit WithdrewERC20(msg.sender, _to, address(_asset), _amount);
}
}
/**
/// @notice 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 _asset ERC721 token to withdraw.
/// @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(
function withdrawERC721(
ERC721 _asset,
ERC721 _asset,
address _to,
address _to,
...
...
packages/contracts-bedrock/contracts/periphery/Transactor.sol
View file @
e175fd8f
...
@@ -3,50 +3,38 @@ pragma solidity ^0.8.0;
...
@@ -3,50 +3,38 @@ pragma solidity ^0.8.0;
import { Owned } from "@rari-capital/solmate/src/auth/Owned.sol";
import { Owned } from "@rari-capital/solmate/src/auth/Owned.sol";
/**
/// @title Transactor
* @title Transactor
/// @notice Transactor is a minimal contract that can send transactions.
* @notice Transactor is a minimal contract that can send transactions.
*/
contract Transactor is Owned {
contract Transactor is Owned {
/**
/// @param _owner Initial contract owner.
* @param _owner Initial contract owner.
*/
constructor(address _owner) Owned(_owner) {}
constructor(address _owner) Owned(_owner) {}
/**
/// @notice Sends a CALL to a target address.
* Sends a CALL to a target address.
/// @param _target Address to call.
*
/// @param _data Data to send with the call.
* @param _target Address to call.
/// @param _value ETH value to send with the call.
* @param _data Data to send with the call.
/// @return success_ Boolean success value.
* @param _value ETH value to send with the call.
/// @return data_ Bytes data returned by the call.
*
* @return Boolean success value.
* @return Bytes data returned by the call.
*/
function CALL(
function CALL(
address _target,
address _target,
bytes memory _data,
bytes memory _data,
uint256 _value
uint256 _value
) external payable onlyOwner returns (bool
, bytes memory
) {
) external payable onlyOwner returns (bool
success_, bytes memory data_
) {
return
_target.call{ value: _value }(_data);
(success_, data_) =
_target.call{ value: _value }(_data);
}
}
/**
/// @notice Sends a DELEGATECALL to a target address.
* Sends a DELEGATECALL to a target address.
/// @param _target Address to call.
*
/// @param _data Data to send with the call.
* @param _target Address to call.
/// @return success_ Boolean success value.
* @param _data Data to send with the call.
/// @return data_ Bytes data returned by the call.
*
* @return Boolean success value.
* @return Bytes data returned by the call.
*/
function DELEGATECALL(address _target, bytes memory _data)
function DELEGATECALL(address _target, bytes memory _data)
external
external
payable
payable
onlyOwner
onlyOwner
returns (bool
, bytes memory
)
returns (bool
success_, bytes memory data_
)
{
{
// slither-disable-next-line controlled-delegatecall
// slither-disable-next-line controlled-delegatecall
return
_target.delegatecall(_data);
(success_, data_) =
_target.delegatecall(_data);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment