LibUtils
Functions
random
simple rng calculation
complexity needs to be increased in prod
function random(uint256 r1, uint256 r2) internal view returns (uint256 r);
Parameters
Name | Type | Description |
---|---|---|
r1 | uint256 | first source of randomness |
r2 | uint256 | second source of randomness |
Returns
Name | Type | Description |
---|---|---|
r | uint256 | random value |
max
Returns the largest of two numbers.
function max(int32 a, int32 b) internal pure returns (int32);
min
Returns the smallest of two numbers.
function min(int32 a, int32 b) internal pure returns (int32);
clamp
Clamps return value to _upperBound
function clamp(uint256 _value, uint256 _upperBound) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_value | uint256 | value to be clamped |
_upperBound | uint256 | upper bound |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | clamped value |
abs
Returns the absolute value
function abs(int32 x) internal pure returns (int32);
absDif
Returns the absolute difference
function absDif(int32 a, int32 b) internal pure returns (uint32);
addressToEntityKey
Conversion from address to bytes32
function addressToEntityKey(address _address) internal pure returns (bytes32 key);
removeFromArray
Removes an element from an array of bytes32
if it exists and returns the new array.
function removeFromArray(bytes32[] memory array, bytes32 element) internal pure returns (bytes32[] memory);
Parameters
Name | Type | Description |
---|---|---|
array | bytes32[] | The original array of bytes32 elements. |
element | bytes32 | The bytes32 element to be removed from the array. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32[] | newArray The new array containing all elements of the original array except for the removed element. |
stringEq
Checks equality of two strings
function stringEq(string memory a, string memory b) internal pure returns (bool);
safeSubtract
Subtract without underflow
function safeSubtract(uint256 a, uint256 b) internal pure returns (uint256);
arrayIncludes
Check if an element is included in an array
function arrayIncludes(bytes14[] memory array, bytes14 element) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
array | bytes14[] | The array to check |
element | bytes14 | The element to check for |