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
50e97622
Commit
50e97622
authored
Jun 23, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port periphery contracts and tests to triple slash natspec styling
parent
759473bb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
61 deletions
+30
-61
TransferOnion.sol
...s/contracts-bedrock/contracts/periphery/TransferOnion.sol
+15
-29
L1StandardBridge.t.sol
...s/contracts-bedrock/contracts/test/L1StandardBridge.t.sol
+1
-1
TransferOnion.t.sol
...ages/contracts-bedrock/contracts/test/TransferOnion.t.sol
+14
-31
No files found.
packages/contracts-bedrock/contracts/periphery/TransferOnion.sol
View file @
50e97622
...
@@ -5,45 +5,34 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuar
...
@@ -5,45 +5,34 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuar
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
/// @title TransferOnion
* @title TransferOnion
/// @notice TransferOnion is a hash onion for distributing tokens. The shell commits
* @notice TransferOnion is a hash onion for distributing tokens. The shell commits
/// to an ordered list of the token transfers and can be permissionlessly
* to an ordered list of the token transfers and can be permissionlessly
/// unwrapped in order. The SENDER must `approve` this contract as
* unwrapped in order. The SENDER must `approve` this contract as
/// `transferFrom` is used to move the token balances.
* `transferFrom` is used to move the token balances.
*/
contract TransferOnion is ReentrancyGuard {
contract TransferOnion is ReentrancyGuard {
using SafeERC20 for ERC20;
using SafeERC20 for ERC20;
/**
/// @notice Struct representing a layer of the onion.
* @notice Struct representing a layer of the onion.
*/
struct Layer {
struct Layer {
address recipient;
address recipient;
uint256 amount;
uint256 amount;
bytes32 shell;
bytes32 shell;
}
}
/**
/// @notice Address of the token to distribute.
* @notice Address of the token to distribute.
*/
ERC20 public immutable TOKEN;
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;
address public immutable SENDER;
/**
/// @notice Current shell hash.
* @notice Current shell hash.
*/
bytes32 public shell;
bytes32 public shell;
/**
/// @notice Constructs a new TransferOnion.
* @param _token Address of the token to distribute.
/// @param _token Address of the token to distribute.
* @param _sender Address of the sender to distribute from.
/// @param _sender Address of the sender to distribute from.
* @param _shell Initial shell of the onion.
/// @param _shell Initial shell of the onion.
*/
constructor(
constructor(
ERC20 _token,
ERC20 _token,
address _sender,
address _sender,
...
@@ -54,11 +43,8 @@ contract TransferOnion is ReentrancyGuard {
...
@@ -54,11 +43,8 @@ contract TransferOnion is ReentrancyGuard {
shell = _shell;
shell = _shell;
}
}
/**
/// @notice Peels layers from the onion and distributes tokens.
* @notice Peels layers from the onion and distributes tokens.
/// @param _layers Array of onion layers to peel.
*
* @param _layers Array of onion layers to peel.
*/
function peel(Layer[] memory _layers) public nonReentrant {
function peel(Layer[] memory _layers) public nonReentrant {
bytes32 tempShell = shell;
bytes32 tempShell = shell;
uint256 length = _layers.length;
uint256 length = _layers.length;
...
...
packages/contracts-bedrock/contracts/test/L1StandardBridge.t.sol
View file @
50e97622
...
@@ -20,7 +20,7 @@ import { OptimismPortal } from "../L1/OptimismPortal.sol";
...
@@ -20,7 +20,7 @@ import { OptimismPortal } from "../L1/OptimismPortal.sol";
contract L1StandardBridge_Getter_Test is Bridge_Initializer {
contract L1StandardBridge_Getter_Test is Bridge_Initializer {
/// @dev Test that the accessors return the correct initialized values.
/// @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.l2TokenBridge() == address(L2Bridge));
assert(L1Bridge.OTHER_BRIDGE() == L2Bridge);
assert(L1Bridge.OTHER_BRIDGE() == L2Bridge);
assert(L1Bridge.messenger() == L1Messenger);
assert(L1Bridge.messenger() == L1Messenger);
...
...
packages/contracts-bedrock/contracts/test/TransferOnion.t.sol
View file @
50e97622
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
pragma solidity 0.8.15;
// Testing utilities
import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/Test.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Target contract
import { TransferOnion } from "../periphery/TransferOnion.sol";
import { TransferOnion } from "../periphery/TransferOnion.sol";
/**
/// @title TransferOnionTest
* @title TransferOnionTest
/// @notice Test coverage of TransferOnion
* @notice Test coverage of TransferOnion
*/
contract TransferOnionTest is Test {
contract TransferOnionTest is Test {
/**
/// @notice TransferOnion
* @notice TransferOnion
*/
TransferOnion internal onion;
TransferOnion internal onion;
/**
/// @notice Token constructor argument
* @notice token constructor arg
*/
address internal _token;
address internal _token;
/**
/// @notice Sender constructor argument
* @notice sender constructor arg
*/
address internal _sender;
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 {
function setUp() public {
ERC20 token = new ERC20("Token", "TKN");
ERC20 token = new ERC20("Token", "TKN");
_token = address(token);
_token = address(token);
_sender = makeAddr("sender");
_sender = makeAddr("sender");
}
}
/**
/// @notice Deploy the TransferOnion with a dummy shell.
* @notice Deploy the TransferOnion with a dummy shell
*/
function _deploy() public {
function _deploy() public {
_deploy(bytes32(0));
_deploy(bytes32(0));
}
}
/**
/// @notice Deploy the TransferOnion with a specific shell.
* @notice Deploy the TransferOnion with a specific shell
*/
function _deploy(bytes32 _shell) public {
function _deploy(bytes32 _shell) public {
onion = new TransferOnion({ _token: ERC20(_token), _sender: _sender, _shell: _shell });
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)
function _onionize(TransferOnion.Layer[] memory _layers)
public
public
pure
pure
...
@@ -66,9 +53,7 @@ contract TransferOnionTest is Test {
...
@@ -66,9 +53,7 @@ contract TransferOnionTest is Test {
return (hash, _layers);
return (hash, _layers);
}
}
/**
/// @notice The constructor sets the variables as expected.
* @notice The constructor sets the variables as expected
*/
function test_constructor_succeeds() external {
function test_constructor_succeeds() external {
_deploy();
_deploy();
...
@@ -77,9 +62,7 @@ contract TransferOnionTest is Test {
...
@@ -77,9 +62,7 @@ contract TransferOnionTest is Test {
assertEq(onion.shell(), bytes32(0));
assertEq(onion.shell(), bytes32(0));
}
}
/**
/// @notice Tests unwrapping the onion.
* @notice unwrap
*/
function test_unwrap_succeeds() external {
function test_unwrap_succeeds() external {
// Commit to transferring tiny amounts of tokens
// Commit to transferring tiny amounts of tokens
TransferOnion.Layer[] memory _layers = new TransferOnion.Layer[](2);
TransferOnion.Layer[] memory _layers = new TransferOnion.Layer[](2);
...
...
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