@sudobility/heavymath_lib
v0.0.92
Published
Business logic library for Heavymath prediction market platform
Maintainers
Readme
@sudobility/heavymath_lib
React hooks library for the Heavymath prediction market platform. Wraps sports data fetching with user favorites from @sudobility/heavymath_indexer_client.
Installation
bun add @sudobility/heavymath_libUsage
Every hook fetches sports data, fetches the user's favorites, then merges them so each item has a favorited flag and a setFavorited() method.
import { useFootballLeagues, useBasketballGames, useF1Drivers } from '@sudobility/heavymath_lib';
function Leagues() {
const { items, isLoading, setFavorited } = useFootballLeagues(indexerClient, walletAddress);
return items.map(league => (
<div key={league.id}>
{league.name} {league.favorited ? '(fav)' : ''}
<button onClick={() => setFavorited(league.id, !league.favorited)}>Toggle</button>
</div>
));
}Available Hooks
Standard Team Sports (8 sports x 3 hooks each)
Football, Basketball, NFL, Baseball, Hockey, Rugby, Handball, Volleyball:
use{Sport}Leagues/use{Sport}Teams/use{Sport}Games- Football uses
useFootballMatches(not Games)
MMA
useMmaCategories,useMmaFighters,useMmaFights
Formula 1
useF1Drivers,useF1Teams,useF1Races,useF1Circuits
Hook Signature
function useXxxYyy(
indexerClient: IndexerClient,
walletAddress: string | undefined,
options?: { params?; enabled? }
): {
items: XxxYyyWithFavorite[];
isLoading: boolean;
isError: boolean;
error: Error | null;
setFavorited: (id: number, favorited: boolean) => Promise<void>;
favoritesLoading: boolean;
addFavoritePending: boolean;
removeFavoritePending: boolean;
}Development
bun run build # Compile TypeScript
bun run test # Run Vitest (187 tests across 32 files)
bun run typecheck # TypeScript validation
bun run lint # ESLint check
bun run verify # Typecheck + lint + testPeer Dependencies
@sudobility/heavymath_indexer_client-- sports data types, proxy hooks, favorites API@sudobility/heavymath_types,@sudobility/types@tanstack/react-query>= 5.0.0,react>= 18.0.0
Related Packages
@sudobility/heavymath_types-- shared type definitions@sudobility/heavymath_indexer_client-- indexer API clientheavymath_app-- frontend web application
License
BUSL-1.1
