@mallow-labs/mallow-util
v0.2.0
Published
Generic utilities and types for any project
Readme
@mallow-labs/mallow-util
Framework-agnostic TypeScript utilities and types used across the Mallow Labs packages — generic enough to be useful on their own. Zero Solana or wallet dependencies.
Install
pnpm add @mallow-labs/mallow-util
# or
npm install @mallow-labs/mallow-utilUsage
import { invariant, getMerkleRoot, shortenAddress, type Maybe } from "@mallow-labs/mallow-util";
invariant(user.id != null, "user.id is required");
const root = getMerkleRoot(["leaf-a", "leaf-b", "leaf-c"]);
const display = shortenAddress("5bZW66SN5ygEjSMUJ2DmQ46K5C2LLZ3i28N4vZJbTcEr");
// "5bZW...TcEr"
const value: Maybe<string> = null; // null | undefined | stringExports
| Symbol | Kind | Purpose |
|---|---|---|
| invariant | function | Throws if the condition is falsy. Narrows TypeScript types. |
| debug, isDebugEnabled | function | Conditional logging gated by MALLOW_DEBUG / MALLOW_DEBUG_LEVEL env vars. |
| getMerkleRoot, getMerkleProof, getMerkleProofAtIndex, getMerkleTree | function | Keccak-256 Merkle utilities backed by merkletreejs. |
| getMimeTypeFromExtension, getArweaveUrlFileExtension | function | File-type lookups. |
| resolveAssetUrl, getAltStorageUrl | function | URL helpers for hosted assets. |
| shortenAddress | function | Render Solana addresses as ABCD...WXYZ. |
| numberToU32LE | function | Encode a number as a 4-byte little-endian buffer. |
| timeoutAsync | function | Reject a promise after N ms. |
| getExplorerAddressUrl, getExplorerTxUrl | function | Build Solana Explorer links. |
| Maybe, Undef, MaybeUndef, AtLeastOne, Common, Resolved | type | Utility types. |
| Chain, ChainLabel | type | Multichain identifiers. |
| AuctionMetadata, AuctionMetadataWithHistory, BaseAuctionMetadata, BuyNowMetadata | type | Marketplace metadata shapes. |
License
MIT
