Skip to content

Commit c8ad799

Browse files
committed
Github Action: Update contract
1 parent c8fdf1a commit c8ad799

File tree

3 files changed

+90
-37
lines changed

3 files changed

+90
-37
lines changed

tutorials/token-bridge-e2e/packages/l1-contracts/contracts/TokenPortal.sol

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol";
66
// Messaging
77
import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol";
88
import {IInbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol";
9+
import {IOutbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol";
910
import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol";
1011
import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol";
1112

@@ -84,13 +85,19 @@ contract TokenPortal {
8485
* @param _recipient - The address to send the funds to
8586
* @param _amount - The amount to withdraw
8687
* @param _withCaller - Flag to use `msg.sender` as caller, otherwise address(0)
88+
* @param _l2BlockNumber - The address to send the funds to
89+
* @param _leafIndex - The amount to withdraw
90+
* @param _path - Flag to use `msg.sender` as caller, otherwise address(0)
8791
* Must match the caller of the message (specified from L2) to consume it.
88-
* @return The key of the entry in the Outbox
8992
*/
90-
function withdraw(address _recipient, uint256 _amount, bool _withCaller)
91-
external
92-
returns (bytes32)
93-
{
93+
function withdraw(
94+
address _recipient,
95+
uint256 _amount,
96+
bool _withCaller,
97+
uint256 _l2BlockNumber,
98+
uint256 _leafIndex,
99+
bytes32[] calldata _path
100+
) external {
94101
DataStructures.L2ToL1Msg memory message = DataStructures.L2ToL1Msg({
95102
sender: DataStructures.L2Actor(l2Bridge, 1),
96103
recipient: DataStructures.L1Actor(address(this), block.chainid),
@@ -104,10 +111,10 @@ contract TokenPortal {
104111
)
105112
});
106113

107-
bytes32 entryKey = registry.getOutbox().consume(message);
114+
IOutbox outbox = registry.getOutbox();
108115

109-
underlying.transfer(_recipient, _amount);
116+
outbox.consume(message, _l2BlockNumber, _leafIndex, _path);
110117

111-
return entryKey;
118+
underlying.transfer(_recipient, _amount);
112119
}
113120
}

tutorials/uniswap-integration-e2e/packages/l1-contracts/contracts/TokenPortal.sol

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol";
66
// Messaging
77
import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol";
88
import {IInbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol";
9+
import {IOutbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol";
910
import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol";
1011
import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol";
1112

@@ -84,13 +85,19 @@ contract TokenPortal {
8485
* @param _recipient - The address to send the funds to
8586
* @param _amount - The amount to withdraw
8687
* @param _withCaller - Flag to use `msg.sender` as caller, otherwise address(0)
88+
* @param _l2BlockNumber - The address to send the funds to
89+
* @param _leafIndex - The amount to withdraw
90+
* @param _path - Flag to use `msg.sender` as caller, otherwise address(0)
8791
* Must match the caller of the message (specified from L2) to consume it.
88-
* @return The key of the entry in the Outbox
8992
*/
90-
function withdraw(address _recipient, uint256 _amount, bool _withCaller)
91-
external
92-
returns (bytes32)
93-
{
93+
function withdraw(
94+
address _recipient,
95+
uint256 _amount,
96+
bool _withCaller,
97+
uint256 _l2BlockNumber,
98+
uint256 _leafIndex,
99+
bytes32[] calldata _path
100+
) external {
94101
DataStructures.L2ToL1Msg memory message = DataStructures.L2ToL1Msg({
95102
sender: DataStructures.L2Actor(l2Bridge, 1),
96103
recipient: DataStructures.L1Actor(address(this), block.chainid),
@@ -104,10 +111,10 @@ contract TokenPortal {
104111
)
105112
});
106113

107-
bytes32 entryKey = registry.getOutbox().consume(message);
114+
IOutbox outbox = registry.getOutbox();
108115

109-
underlying.transfer(_recipient, _amount);
116+
outbox.consume(message, _l2BlockNumber, _leafIndex, _path);
110117

111-
return entryKey;
118+
underlying.transfer(_recipient, _amount);
112119
}
113120
}

tutorials/uniswap-integration-e2e/packages/l1-contracts/contracts/UniswapPortal.sol

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ pragma solidity >=0.8.18;
33
import {IERC20} from "@oz/token/ERC20/IERC20.sol";
44

55
import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol";
6+
import {IOutbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol";
67
import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol";
8+
import {DataStructures as PortalDataStructures} from "./DataStructures.sol";
79
import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol";
810

911
import {TokenPortal} from "./TokenPortal.sol";
@@ -48,7 +50,7 @@ contract UniswapPortal {
4850
* @param _aztecRecipient - The aztec address to receive the output assets
4951
* @param _secretHashForL1ToL2Message - The hash of the secret consumable message. The hash should be 254 bits (so it can fit in a Field element)
5052
* @param _withCaller - When true, using `msg.sender` as the caller, otherwise address(0)
51-
* @return The entryKey of the deposit transaction in the Inbox
53+
* @return A hash of the L1 to L2 message inserted in the Inbox
5254
*/
5355
function swapPublic(
5456
address _inputTokenPortal,
@@ -58,15 +60,27 @@ contract UniswapPortal {
5860
uint256 _amountOutMinimum,
5961
bytes32 _aztecRecipient,
6062
bytes32 _secretHashForL1ToL2Message,
61-
bool _withCaller
63+
bool _withCaller,
64+
// Avoiding stack too deep
65+
PortalDataStructures.OutboxMessageMetadata[2] calldata _outboxMessageMetadata
6266
) public returns (bytes32) {
6367
LocalSwapVars memory vars;
6468

6569
vars.inputAsset = TokenPortal(_inputTokenPortal).underlying();
6670
vars.outputAsset = TokenPortal(_outputTokenPortal).underlying();
6771

6872
// Withdraw the input asset from the portal
69-
TokenPortal(_inputTokenPortal).withdraw(address(this), _inAmount, true);
73+
{
74+
TokenPortal(_inputTokenPortal).withdraw(
75+
address(this),
76+
_inAmount,
77+
true,
78+
_outboxMessageMetadata[0]._l2BlockNumber,
79+
_outboxMessageMetadata[0]._leafIndex,
80+
_outboxMessageMetadata[0]._path
81+
);
82+
}
83+
7084
{
7185
// prevent stack too deep errors
7286
vars.contentHash = Hash.sha256ToField(
@@ -85,13 +99,20 @@ contract UniswapPortal {
8599
}
86100

87101
// Consume the message from the outbox
88-
registry.getOutbox().consume(
89-
DataStructures.L2ToL1Msg({
90-
sender: DataStructures.L2Actor(l2UniswapAddress, 1),
91-
recipient: DataStructures.L1Actor(address(this), block.chainid),
92-
content: vars.contentHash
93-
})
94-
);
102+
{
103+
IOutbox outbox = registry.getOutbox();
104+
105+
outbox.consume(
106+
DataStructures.L2ToL1Msg({
107+
sender: DataStructures.L2Actor(l2UniswapAddress, 1),
108+
recipient: DataStructures.L1Actor(address(this), block.chainid),
109+
content: vars.contentHash
110+
}),
111+
_outboxMessageMetadata[1]._l2BlockNumber,
112+
_outboxMessageMetadata[1]._leafIndex,
113+
_outboxMessageMetadata[1]._path
114+
);
115+
}
95116

96117
// Perform the swap
97118
ISwapRouter.ExactInputSingleParams memory swapParams;
@@ -134,7 +155,7 @@ contract UniswapPortal {
134155
* @param _secretHashForRedeemingMintedNotes - The hash of the secret to redeem minted notes privately on Aztec. The hash should be 254 bits (so it can fit in a Field element)
135156
* @param _secretHashForL1ToL2Message - The hash of the secret consumable message. The hash should be 254 bits (so it can fit in a Field element)
136157
* @param _withCaller - When true, using `msg.sender` as the caller, otherwise address(0)
137-
* @return The entryKey of the deposit transaction in the Inbox
158+
* @return A hash of the L1 to L2 message inserted in the Inbox
138159
*/
139160
function swapPrivate(
140161
address _inputTokenPortal,
@@ -144,15 +165,26 @@ contract UniswapPortal {
144165
uint256 _amountOutMinimum,
145166
bytes32 _secretHashForRedeemingMintedNotes,
146167
bytes32 _secretHashForL1ToL2Message,
147-
bool _withCaller
168+
bool _withCaller,
169+
// Avoiding stack too deep
170+
PortalDataStructures.OutboxMessageMetadata[2] calldata _outboxMessageMetadata
148171
) public returns (bytes32) {
149172
LocalSwapVars memory vars;
150173

151174
vars.inputAsset = TokenPortal(_inputTokenPortal).underlying();
152175
vars.outputAsset = TokenPortal(_outputTokenPortal).underlying();
153176

154-
// Withdraw the input asset from the portal
155-
TokenPortal(_inputTokenPortal).withdraw(address(this), _inAmount, true);
177+
{
178+
TokenPortal(_inputTokenPortal).withdraw(
179+
address(this),
180+
_inAmount,
181+
true,
182+
_outboxMessageMetadata[0]._l2BlockNumber,
183+
_outboxMessageMetadata[0]._leafIndex,
184+
_outboxMessageMetadata[0]._path
185+
);
186+
}
187+
156188
{
157189
// prevent stack too deep errors
158190
vars.contentHash = Hash.sha256ToField(
@@ -171,13 +203,20 @@ contract UniswapPortal {
171203
}
172204

173205
// Consume the message from the outbox
174-
registry.getOutbox().consume(
175-
DataStructures.L2ToL1Msg({
176-
sender: DataStructures.L2Actor(l2UniswapAddress, 1),
177-
recipient: DataStructures.L1Actor(address(this), block.chainid),
178-
content: vars.contentHash
179-
})
180-
);
206+
{
207+
IOutbox outbox = registry.getOutbox();
208+
209+
outbox.consume(
210+
DataStructures.L2ToL1Msg({
211+
sender: DataStructures.L2Actor(l2UniswapAddress, 1),
212+
recipient: DataStructures.L1Actor(address(this), block.chainid),
213+
content: vars.contentHash
214+
}),
215+
_outboxMessageMetadata[1]._l2BlockNumber,
216+
_outboxMessageMetadata[1]._leafIndex,
217+
_outboxMessageMetadata[1]._path
218+
);
219+
}
181220

182221
// Perform the swap
183222
ISwapRouter.ExactInputSingleParams memory swapParams;

0 commit comments

Comments
 (0)