From 12818d45c2d0167529b8d49f845fdfff2fac16ff Mon Sep 17 00:00:00 2001 From: Anna Carroll Date: Mon, 10 Jun 2024 17:37:00 -0500 Subject: [PATCH] WIP: feat: transact flow --- src/Passage.sol | 58 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/src/Passage.sol b/src/Passage.sol index 9c4de52..2757fba 100644 --- a/src/Passage.sol +++ b/src/Passage.sol @@ -21,6 +21,18 @@ contract Passage { /// @param amount - The amount of the token entering the rollup. event Enter(uint256 indexed rollupChainId, address indexed token, address indexed rollupRecipient, uint256 amount); + /// @notice Emitted to send a special transaction to the rollup. + event Transact( + uint256 indexed rollupChainId, + address indexed sender, + address indexed to, + bytes data, + uint256 value, + uint256 gas, + uint256 maxPrioFee, + uint256 maxBaseFee + ); + /// @notice Emitted when the admin withdraws tokens from the contract. event Withdrawal(address indexed token, address indexed recipient, uint256 amount); @@ -41,13 +53,6 @@ contract Passage { enter(defaultRollupChainId, msg.sender); } - /// @notice Allows native Ether to enter the rollup. - /// @param rollupRecipient - The recipient of the Ether on the rollup. - /// @custom:emits Enter indicating the amount of Ether to mint on the rollup & its recipient. - function enter(address rollupRecipient) public payable { - enter(defaultRollupChainId, rollupRecipient); - } - /// @notice Allows native Ether to enter the rollup. /// @param rollupChainId - The rollup chain to enter. /// @param rollupRecipient - The recipient of the Ether on the rollup. @@ -56,6 +61,45 @@ contract Passage { emit Enter(rollupChainId, address(0), rollupRecipient, msg.value); } + /// @dev See `enter` above for docs. + function enter(address rollupRecipient) external payable { + enter(defaultRollupChainId, rollupRecipient); + } + + /// @notice Allows a special transaction to be sent to the rollup with sender == L1 msg.sender. + /// @dev Transaction is processed after normal rollup block execution. + /// @param rollupChainId - The rollup chain to send the transaction to. + /// @param to - The address to call on the rollup. + /// @param data - The data to send to the rollup. + /// @param value - The amount of Ether to send on the rollup. + /// @param gas - The gas limit for the transaction. + /// @param maxPrioFee - The maximum priority fee for the transaction. + /// @param maxBaseFee - The maximum base fee for the transaction. + /// @custom:emits Transact indicating the transaction to mine on the rollup. + function transact( + uint256 rollupChainId, + address to, + bytes calldata data, + uint256 value, + uint256 gas, + uint256 maxPrioFee, + uint256 maxBaseFee + ) public { + emit Transact(rollupChainId, msg.sender, to, data, value, gas, maxPrioFee, maxBaseFee); + } + + /// @dev See `transact` above for docs. + function transact( + address to, + bytes calldata data, + uint256 value, + uint256 gas, + uint256 maxPrioFee, + uint256 maxBaseFee + ) external { + transact(defaultRollupChainId, to, data, value, gas, maxPrioFee, maxBaseFee); + } + /// @notice Allows the admin to withdraw ETH or ERC20 tokens from the contract. /// @dev Only the admin can call this function. function withdraw(address token, address recipient, uint256 amount) external {