Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 234 additions & 69 deletions contracts/src/Bridge.sol

Large diffs are not rendered by default.

31 changes: 22 additions & 9 deletions contracts/src/interfaces/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,32 @@ interface IBridge {
* @param payload Encoded function call data (e.g., `abi.encodeWithSignature("transfer(address,uint256)", recipient, amount)`)
* @param sequencerSignature Signature from the trusted TEE sequencer.
* @param nativeTokenAmount Amount of native token to transfer with the call
* @param deadline Timestamp after which message cannot be executed (0 = no deadline)
*/
function initializeMessage(
bytes32 messageId,
address targetAddress,
bytes calldata payload,
SequencerSignature calldata sequencerSignature,
uint256 nativeTokenAmount
uint256 nativeTokenAmount,
uint256 deadline
) external;

/**
* @notice Executes a previously initialized message
* @dev Execution follows these steps:
* 1. Validates message is in PreExecution stage (see ProcessingStage enum in DataTypes.sol)
* 2. Runs all pre-execution validation modules (ModuleCheck)
* 3. Unwraps native tokens if nativeTokenAmount > 0
* 4. Executes the call to targetAddress with payload
* 5. Re-wraps any returned native tokens
* 6. Runs all post-execution validation modules (ModuleCheck)
* 7. Marks message as Completed
* 2. Checks message has not expired (deadline not passed)
* 3. Runs all pre-execution validation modules (ModuleCheck)
* 4. Unwraps native tokens if nativeTokenAmount > 0
* 5. Executes the call to targetAddress with payload (with gas limit)
* 6. Re-wraps any returned native tokens
* 7. Runs all post-execution validation modules (ModuleCheck)
* 8. Marks message as Completed
* @param messageId Unique identifier of the message to execute
* @param payload The original payload (must match stored hash)
*/
function handleMessage(bytes32 messageId) external;
function handleMessage(bytes32 messageId, bytes calldata payload) external;

/**
* @notice Initializes and immediately executes a message in a single transaction
Expand All @@ -55,16 +59,25 @@ interface IBridge {
* @param validatorSignatures Array of signatures from authorized validators. Can be empty if running in sequencer-only
* mode or if no validator signature threshold module is configured.
* @param nativeTokenAmount Amount of native token to transfer with the call
* @param deadline Timestamp after which message cannot be executed (0 = no deadline)
*/
function initializeAndHandleMessage(
bytes32 messageId,
address targetAddress,
bytes calldata payload,
SequencerSignature calldata sequencerSignature,
bytes[] calldata validatorSignatures,
uint256 nativeTokenAmount
uint256 nativeTokenAmount,
uint256 deadline
) external;

/**
* @notice Cancels an initialized message that has not yet been executed
* @dev Only callable by owner. Message must be in PreExecution stage.
* @param messageId Unique identifier of the message to cancel
*/
function cancelMessage(bytes32 messageId) external;

/**
* @notice Checks if a message has been successfully completed
* @param messageId Unique identifier of the message
Expand Down
3 changes: 2 additions & 1 deletion contracts/src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ struct MessageState {
bytes32 messageId; // Unique identifier for the message
address targetAddress; // Address that will receive the message call
ProcessingStage stage; // Current processing stage
bytes payload; // Encoded function call data
bytes32 payloadHash; // Hash of encoded function call data (storage optimization)
uint256 createdAt; // Block timestamp when message was created
uint256 deadline; // Timestamp after which message cannot be executed (0 = no deadline)
uint256 nativeTokenAmount; // Amount of native token to transfer with call
}

Expand Down
Loading