CommonLib

Git Source

Title: CommonLib

Author: Merge Layers Inc.

Shared helper utilities for validation and math

Functions

checkHostToExtension

Checks a host to extension call for validity

function checkHostToExtension(
    uint256 amount,
    uint32 dstChainId,
    uint256 msgValue,
    mapping(uint32 => bool) storage allowedChains,
    IGasFeesHelper gasHelper
) internal view;

Parameters

NameTypeDescription
amountuint256Amount being transferred
dstChainIduint32Destination chain id
msgValueuint256Message value provided
allowedChainsmapping(uint32 => bool)Mapping of allowed chain ids
gasHelperIGasFeesHelperGas helper contract

checkLengthMatch

Ensures two lengths match

function checkLengthMatch(uint256 l1, uint256 l2) internal pure;

Parameters

NameTypeDescription
l1uint256First length
l2uint256Second length

checkLengthMatch

Ensures three lengths match

function checkLengthMatch(uint256 l1, uint256 l2, uint256 l3) internal pure;

Parameters

NameTypeDescription
l1uint256First length
l2uint256Second length
l3uint256Third length

computeSum

Computes sum of an array

function computeSum(uint256[] calldata values) internal pure returns (uint256 sum);

Parameters

NameTypeDescription
valuesuint256[]Array of values

Returns

NameTypeDescription
sumuint256Total sum

Errors

CommonLib_LengthMismatch

Thrown when array lengths mismatch

error CommonLib_LengthMismatch();

AmountNotValid

Thrown when amount is invalid

error AmountNotValid();

ChainNotValid

Thrown when chain id is not allowed

error ChainNotValid();

NotEnoughGasFee

Thrown when provided gas fee is insufficient

error NotEnoughGasFee();