Skip to content

Commit 8fc4188

Browse files
committed
fix: ownable constructor invocation
1 parent 9af82ed commit 8fc4188

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/apps/Bridge.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ abstract contract BridgeL2 is SignetL2, BurnMintERC20 {
2222

2323
/// @notice Bridges assets into the rollup for a given recipient.
2424
function _bridgeIn(address recipient, uint256 amount, RollupOrders.Input[] memory inputs) internal virtual {
25+
_mint(recipient, amount);
26+
2527
RollupOrders.Output[] memory outputs = new RollupOrders.Output[](1);
2628
outputs[0] = makeHostOutput(HOST_ASSET, amount, HOST_BANK);
2729

2830
ORDERS.initiate(block.timestamp, inputs, outputs);
2931

30-
_mint(recipient, amount);
3132
}
3233

3334
/// @notice Bridges assets into the rollup for a given recipient.
@@ -41,12 +42,13 @@ abstract contract BridgeL2 is SignetL2, BurnMintERC20 {
4142
/// This transaction should be paired with some off-chain logic that fills
4243
/// orders from the L1 bank.
4344
function _bridgeOut(address recipient, uint256 amount, RollupOrders.Input[] memory inputs) internal virtual {
45+
burnFrom(msg.sender, amount);
46+
4447
RollupOrders.Output[] memory outputs = new RollupOrders.Output[](1);
4548
outputs[0] = makeHostOutput(HOST_ASSET, amount, recipient);
4649

4750
ORDERS.initiate(block.timestamp, inputs, outputs);
4851

49-
_burn(msg.sender, amount);
5052
}
5153

5254
/// @notice Burn asset on L2, and create an order to bridge out asset to

src/l2/SelfOwned.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
66
import {SignetL2} from "./Signet.sol";
77

88
abstract contract SelfOwned is SignetL2, Ownable {
9-
constructor() {
10-
Ownable(aliasedSelf());
11-
}
9+
constructor() Ownable(aliasedSelf()) {}
1210
}

test/SelfOwned.sol

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ pragma solidity ^0.8.13;
44
import {SimpleERC20} from "simple-erc20/SimpleERC20.sol";
55

66
import {PecorinoTest} from "./Base.sol";
7+
78
import {SignetL2} from "../src/l2/Signet.sol";
9+
import {SelfOwned} from "../src/l2/SelfOwned.sol";
810
import {AddressAliasHelper} from "../src/vendor/AddressAliasHelper.sol";
911

12+
contract SelfOwnedNothing is SelfOwned {
13+
constructor() {}
14+
}
15+
1016
contract SelfOwnedToken is SignetL2, SimpleERC20 {
1117
constructor() SimpleERC20(aliasedSelf(), "My Token", "MTK", 18) {
1218
assert(HOST_WETH != address(0));
@@ -16,11 +22,18 @@ contract SelfOwnedToken is SignetL2, SimpleERC20 {
1622
contract TestSelfOwned is PecorinoTest {
1723
SelfOwnedToken token;
1824

25+
SelfOwnedNothing nothing;
26+
1927
constructor() {
2028
token = new SelfOwnedToken();
29+
nothing = new SelfOwnedNothing();
2130
}
2231

23-
function test_ownerIsSelfOnL1() public view {
32+
function test_tokenOwnerIsSelfOnL1() public view {
2433
assertEq(token.owner(), AddressAliasHelper.applyL1ToL2Alias(address(token)));
2534
}
35+
36+
function test_nothingOwnerIsSelfOnL1() public view {
37+
assertEq(nothing.owner(), AddressAliasHelper.applyL1ToL2Alias(address(nothing)));
38+
}
2639
}

0 commit comments

Comments
 (0)