Skip to content

Commit

Permalink
WIP: feat: transact flow
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-carroll committed Jun 10, 2024
1 parent 5d70919 commit 12818d4
Showing 1 changed file with 51 additions and 7 deletions.
58 changes: 51 additions & 7 deletions src/Passage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.
Expand All @@ -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 {
Expand Down

0 comments on commit 12818d4

Please sign in to comment.