CommonLib
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
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount being transferred |
dstChainId | uint32 | Destination chain id |
msgValue | uint256 | Message value provided |
allowedChains | mapping(uint32 => bool) | Mapping of allowed chain ids |
gasHelper | IGasFeesHelper | Gas helper contract |
checkLengthMatch
Ensures two lengths match
function checkLengthMatch(uint256 l1, uint256 l2) internal pure;
Parameters
| Name | Type | Description |
|---|---|---|
l1 | uint256 | First length |
l2 | uint256 | Second length |
checkLengthMatch
Ensures three lengths match
function checkLengthMatch(uint256 l1, uint256 l2, uint256 l3) internal pure;
Parameters
| Name | Type | Description |
|---|---|---|
l1 | uint256 | First length |
l2 | uint256 | Second length |
l3 | uint256 | Third length |
computeSum
Computes sum of an array
function computeSum(uint256[] calldata values) internal pure returns (uint256 sum);
Parameters
| Name | Type | Description |
|---|---|---|
values | uint256[] | Array of values |
Returns
| Name | Type | Description |
|---|---|---|
sum | uint256 | Total 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();