Files
smom-dbis-138/contracts/bridge/interfaces/IChainAdapter.sol
2026-03-02 12:14:09 -08:00

85 lines
2.2 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title IChainAdapter
* @notice Interface for chain-specific bridge adapters
* @dev All chain adapters must implement this interface
*/
interface IChainAdapter {
enum BridgeStatus {
Pending,
Locked,
Confirmed,
Completed,
Failed,
Cancelled
}
struct BridgeRequest {
address sender;
address token;
uint256 amount;
bytes destinationData; // Chain-specific destination (address, account, etc.)
bytes32 requestId;
BridgeStatus status;
uint256 createdAt;
uint256 completedAt;
}
/**
* @notice Get chain type identifier
*/
function getChainType() external pure returns (string memory);
/**
* @notice Get chain identifier (chainId for EVM, string for non-EVM)
*/
function getChainIdentifier() external view returns (uint256 chainId, string memory identifier);
/**
* @notice Validate destination address/identifier for this chain
*/
function validateDestination(bytes calldata destination) external pure returns (bool);
/**
* @notice Initiate bridge operation
* @param token Token address (address(0) for native)
* @param amount Amount to bridge
* @param destination Chain-specific destination data
* @param recipient Recipient address/identifier
* @return requestId Unique request identifier
*/
function bridge(
address token,
uint256 amount,
bytes calldata destination,
bytes calldata recipient
) external payable returns (bytes32 requestId);
/**
* @notice Get bridge request status
*/
function getBridgeStatus(bytes32 requestId)
external view returns (BridgeRequest memory);
/**
* @notice Cancel pending bridge (if supported)
*/
function cancelBridge(bytes32 requestId) external returns (bool);
/**
* @notice Estimate bridge fee
*/
function estimateFee(
address token,
uint256 amount,
bytes calldata destination
) external view returns (uint256 fee);
/**
* @notice Check if adapter is active
*/
function isActive() external view returns (bool);
}