Provides functionality for extracting information from calldata and verifying it.
Use the extractBridgeData
method to extract BridgeData from calldata.
/// @notice Extracts the bridge data from the calldata
/// @param data The calldata to extract the bridge data from
/// @return bridgeData The bridge data extracted from the calldata
function extractBridgeData(
bytes calldata data
) external pure returns (BridgeData memory)
Use the extractSwapData
method to extract SwapData from calldata.
/// @notice Extracts the swap data from the calldata
/// @param data The calldata to extract the swap data from
/// @return swapData The swap data extracted from the calldata
function extractSwapData(
bytes calldata data
) external pure returns (SwapData[] memory)
Use the extractMainParameters
method to extract main parameters from calldata.
/// @notice Extracts the main parameters from the calldata
/// @param data The calldata to extract the main parameters from
/// @return bridge The bridge extracted from the calldata
/// @return sendingAssetId The sending asset id extracted from the calldata
/// @return receiver The receiver extracted from the calldata
/// @return amount The min amountfrom the calldata
/// @return destinationChainId The destination chain id extracted from the calldata
/// @return hasSourceSwaps Whether the calldata has source swaps
/// @return hasDestinationCall Whether the calldata has a destination call
function extractMainParameters(
bytes calldata data
)
public
pure
returns (
string memory bridge,
address sendingAssetId,
address receiver,
uint256 amount,
uint256 destinationChainId,
bool hasSourceSwaps,
bool hasDestinationCall
)
Use the extractGenericSwapParameters
method to extract generic parameters related to swap from calldata.
/// @notice Extracts the generic swap parameters from the calldata
/// @param data The calldata to extract the generic swap parameters from
/// @return sendingAssetId The sending asset id extracted from the calldata
/// @return amount The amount extracted from the calldata
/// @return receiver The receiver extracted from the calldata
/// @return receivingAssetId The receiving asset id extracted from the calldata
/// @return receivingAmount The receiving amount extracted from the calldata
function extractGenericSwapParameters(
bytes calldata data
)
public
pure
returns (
address sendingAssetId,
uint256 amount,
address receiver,
address receivingAssetId,
uint256 receivingAmount
)
Use the validateCalldata
method to check whether the calldata is valid or not.
/// @notice Validates the calldata
/// @param data The calldata to validate
/// @param bridge The bridge to validate or empty string to ignore
/// @param sendingAssetId The sending asset id to validate
/// or 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF to ignore
/// @param receiver The receiver to validate
/// or 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF to ignore
/// @param amount The amount to validate or type(uint256).max to ignore
/// @param destinationChainId The destination chain id to validate
/// or type(uint256).max to ignore
/// @param hasSourceSwaps Whether the calldata has source swaps
/// @param hasDestinationCall Whether the calldata has a destination call
/// @return isValid Whether the calldata is validate
function validateCalldata(
bytes calldata data,
string calldata bridge,
address sendingAssetId,
address receiver,
uint256 amount,
uint256 destinationChainId,
bool hasSourceSwaps,
bool hasDestinationCall
) external pure returns (bool isValid)
Use the validateDestinationCalldata
method to check whether the calldata for destination call is valid or not.
/// @notice Validates the destination calldata
/// @param data The calldata to validate
/// @param callTo The call to address to validate
/// @param dstCalldata The destination calldata to validate
/// @return isValid Whether the destination calldata is validate
function validateDestinationCalldata(
bytes calldata data,
bytes calldata callTo,
bytes calldata dstCalldata
) external pure returns (bool isValid)