Commit 50e97622 authored by Andreas Bigger's avatar Andreas Bigger

Port periphery contracts and tests to triple slash natspec styling

parent 759473bb
......@@ -5,45 +5,34 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuar
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title TransferOnion
* @notice TransferOnion is a hash onion for distributing tokens. The shell commits
* to an ordered list of the token transfers and can be permissionlessly
* unwrapped in order. The SENDER must `approve` this contract as
* `transferFrom` is used to move the token balances.
*/
/// @title TransferOnion
/// @notice TransferOnion is a hash onion for distributing tokens. The shell commits
/// to an ordered list of the token transfers and can be permissionlessly
/// unwrapped in order. The SENDER must `approve` this contract as
/// `transferFrom` is used to move the token balances.
contract TransferOnion is ReentrancyGuard {
using SafeERC20 for ERC20;
/**
* @notice Struct representing a layer of the onion.
*/
/// @notice Struct representing a layer of the onion.
struct Layer {
address recipient;
uint256 amount;
bytes32 shell;
}
/**
* @notice Address of the token to distribute.
*/
/// @notice Address of the token to distribute.
ERC20 public immutable TOKEN;
/**
* @notice Address of the account to distribute tokens from.
*/
/// @notice Address of the account to distribute tokens from.
address public immutable SENDER;
/**
* @notice Current shell hash.
*/
/// @notice Current shell hash.
bytes32 public shell;
/**
* @param _token Address of the token to distribute.
* @param _sender Address of the sender to distribute from.
* @param _shell Initial shell of the onion.
*/
/// @notice Constructs a new TransferOnion.
/// @param _token Address of the token to distribute.
/// @param _sender Address of the sender to distribute from.
/// @param _shell Initial shell of the onion.
constructor(
ERC20 _token,
address _sender,
......@@ -54,11 +43,8 @@ contract TransferOnion is ReentrancyGuard {
shell = _shell;
}
/**
* @notice Peels layers from the onion and distributes tokens.
*
* @param _layers Array of onion layers to peel.
*/
/// @notice Peels layers from the onion and distributes tokens.
/// @param _layers Array of onion layers to peel.
function peel(Layer[] memory _layers) public nonReentrant {
bytes32 tempShell = shell;
uint256 length = _layers.length;
......
......@@ -20,7 +20,7 @@ import { OptimismPortal } from "../L1/OptimismPortal.sol";
contract L1StandardBridge_Getter_Test is Bridge_Initializer {
/// @dev Test that the accessors return the correct initialized values.
function test_getters_succeeds() external {
function test_getters_succeeds() external view {
assert(L1Bridge.l2TokenBridge() == address(L2Bridge));
assert(L1Bridge.OTHER_BRIDGE() == L2Bridge);
assert(L1Bridge.messenger() == L1Messenger);
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing utilities
import { Test } from "forge-std/Test.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Target contract
import { TransferOnion } from "../periphery/TransferOnion.sol";
/**
* @title TransferOnionTest
* @notice Test coverage of TransferOnion
*/
/// @title TransferOnionTest
/// @notice Test coverage of TransferOnion
contract TransferOnionTest is Test {
/**
* @notice TransferOnion
*/
/// @notice TransferOnion
TransferOnion internal onion;
/**
* @notice token constructor arg
*/
/// @notice Token constructor argument
address internal _token;
/**
* @notice sender constructor arg
*/
/// @notice Sender constructor argument
address internal _sender;
/**
* @notice Sets up addresses, deploys contracts and funds the owner.
*/
/// @notice Sets up addresses, deploys contracts and funds the owner.
function setUp() public {
ERC20 token = new ERC20("Token", "TKN");
_token = address(token);
_sender = makeAddr("sender");
}
/**
* @notice Deploy the TransferOnion with a dummy shell
*/
/// @notice Deploy the TransferOnion with a dummy shell.
function _deploy() public {
_deploy(bytes32(0));
}
/**
* @notice Deploy the TransferOnion with a specific shell
*/
/// @notice Deploy the TransferOnion with a specific shell.
function _deploy(bytes32 _shell) public {
onion = new TransferOnion({ _token: ERC20(_token), _sender: _sender, _shell: _shell });
}
/**
* @notice Build the onion data
*/
/// @notice Build the onion data.
function _onionize(TransferOnion.Layer[] memory _layers)
public
pure
......@@ -66,9 +53,7 @@ contract TransferOnionTest is Test {
return (hash, _layers);
}
/**
* @notice The constructor sets the variables as expected
*/
/// @notice The constructor sets the variables as expected.
function test_constructor_succeeds() external {
_deploy();
......@@ -77,9 +62,7 @@ contract TransferOnionTest is Test {
assertEq(onion.shell(), bytes32(0));
}
/**
* @notice unwrap
*/
/// @notice Tests unwrapping the onion.
function test_unwrap_succeeds() external {
// Commit to transferring tiny amounts of tokens
TransferOnion.Layer[] memory _layers = new TransferOnion.Layer[](2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment