@@ -22,12 +22,12 @@ 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);
29-
30- _mint (recipient, amount);
3131 }
3232
3333 /// @notice Bridges assets into the rollup for a given recipient.
@@ -40,21 +40,38 @@ abstract contract BridgeL2 is SignetL2, BurnMintERC20 {
4040 ///
4141 /// This transaction should be paired with some off-chain logic that fills
4242 /// orders from the L1 bank.
43- function _bridgeOut (address recipient , uint256 amount , RollupOrders.Input[] memory inputs ) internal virtual {
43+ function _bridgeOut (address sender , address recipient , uint256 amount , RollupOrders.Input[] memory inputs )
44+ internal
45+ virtual
46+ {
47+ if (_msgSender () != sender) {
48+ _spendAllowance (sender, _msgSender (), amount);
49+ }
50+
51+ _burn (msg .sender , amount);
52+
4453 RollupOrders.Output[] memory outputs = new RollupOrders.Output [](1 );
4554 outputs[0 ] = makeHostOutput (HOST_ASSET, amount, recipient);
4655
4756 ORDERS.initiate (block .timestamp , inputs, outputs);
48-
49- _burn (msg .sender , amount);
5057 }
5158
52- /// @notice Burn asset on L2, and create an order to bridge out asset to
59+ /// @notice Burn asset on L2, and create an order to bridge out assets to
5360 /// L1. If the order is not filled, the asset will not be burned.
5461 ///
5562 /// This transaction should be paired with some off-chain logic that fills
5663 /// orders from the L1 bank.
5764 function bridgeOut (address recipient , uint256 amount ) public virtual {
58- _bridgeOut (recipient, amount, new RollupOrders.Input [](0 ));
65+ _bridgeOut (msg .sender , recipient, amount, new RollupOrders.Input [](0 ));
66+ }
67+
68+ /// @notice Burn asset on L2 from `sender`, and create an order to bridge
69+ /// out assets to L1. If the order is not filled, the asset will not be
70+ /// burned. Used when the caller is not the sender.
71+ ///
72+ /// This transaction should be paired with some off-chain logic that fills
73+ /// orders from the L1 bank.
74+ function bridgeOutFrom (address sender , address recipient , uint256 amount ) public virtual {
75+ _bridgeOut (sender, recipient, amount, new RollupOrders.Input [](0 ));
5976 }
6077}
0 commit comments