💡 In progress. Clave Utils
clave-utils is a utility package that provides a collection of commonly used functions designed to enhance development efficiency across multiple applications. These functions encapsulate repetitive tasks and common patterns, making them easily accessible and reusable. By centralizing these utilities, clave-utils promotes consistent coding practices and accelerates development across projects.
Installation
Currently, since we are in monorepo, you can add clave-utils
to your dependencies to use the existing functions from clave-utils.
{
"dependencies": {
...
"@getclave/utils": "*",
}
}
Available Functions
import {
// validates whether a given string is a valid email address.
HexString,
abiCoder, // ethers.utils.AbiCoder()
bufferToHex, // checks if given addresses valid or not
dateToString, // format date to month.day.year string // converts buffer to hex
derPublicToCoordinates, // converts DER public key to coordinates
derPublicToRaw, // converts DER public key to raw representation
derSignatureToRs, // converts DER signature to R and S
filterNulls, // filters out null or undefined values from an array
formatHex, // adds 0x to hex
getFatSignature, // converting a custom signature and public key into a concatenated format.
hexToBuffer,
isAddressValid, // converts hex to buffer
isEmpty, // checks if a string or array is empty.
nullThrows, // throws an error if the value is `null` or `undefined`
parseHex, // converts string to HexString
shortenPublicAddress, // shortens an address with ellipsis.
stringToHex, // converts string to hex // `0x${string}`
toHexString, // removes 0x from hex
validateEmail,
} from '@getclave/utils';