@leapwallet/ondo-gm-core
v1.0.1
Published
Core package providing fundamental building blocks for Ondo protocol integration - transaction clients, query utilities, state management, and TypeScript types
Readme
@leapwallet/ondo-gm-core
Core package providing fundamental building blocks for Ondo protocol integration - transaction clients, query utilities, state management, and TypeScript types.
Features
- 🔧 Transaction Clients: Prepare and execute Ondo protocol transactions
- 📊 Query Utilities: TanStack Query configurations for API data fetching
- 🏪 State Management: MobX-based state stores for application data
- 📝 TypeScript Types: Comprehensive type definitions for all Ondo protocol entities
Installation
npm install @leapwallet/ondo-gm-core
# or
pnpm add @leapwallet/ondo-gm-core
# or
yarn add @leapwallet/ondo-gm-coreQuick Start
Basic Setup
import { OndoGMApi } from '@leapwallet/ondo-gm-core';
// Initialize the API client
const apiClient = new OndoGMApi({
baseUrl: 'https://api.ondo.finance',
});Query Utilities
The core package provides pre-configured query options for use with TanStack Query:
import { useQuery } from '@tanstack/react-query';
import { getAssetPriceQuery, getAssetsQuery } from '@leapwallet/ondo-gm-core';
// Fetch all asset prices
const assetsQuery = getAssetsQuery(apiClient);
const { data: assets } = useQuery(assetsQuery);
// Fetch specific asset price
const assetPriceQuery = getAssetPriceQuery(apiClient, {
asset: 'USDC',
});
const { data: price } = useQuery(assetPriceQuery);Transaction Client
import { ChainType, type TransactionParams } from '@leapwallet/ondo-gm-core';
// Prepare transaction parameters
const transactionParams: TransactionParams = {
chainId: '1',
fromAddress: '0x...',
toAddress: '0x...',
amount: '1000000', // 1 USDC (6 decimals)
// ... other required fields
};
// Transaction preparation and execution would be handled by chain-specific clients
// (see @leapwallet/ondo-gm-evm-client for EVM implementation)State Management
import { OndoGMState } from '@leapwallet/ondo-gm-core';
// Access the global state store
const store = OndoGMState.baseState;
// The state is observable with MobX
// Use with @leapwallet/ondo-gm-react-adapter for React integrationAPI Reference
Query Functions
getAssetsQuery(apiClient, options?)- Fetch all asset pricesgetAssetPriceQuery(apiClient, query)- Fetch specific asset pricegetMarketQuery(apiClient, query)- Fetch market datagetOHLCQuery(apiClient, query)- Fetch OHLC (candlestick) datagetAccountQuery(apiClient, query)- Fetch account information
Transaction Types
ChainType- Supported blockchain types (ETHEREUM, SOLANA)TransactionParams- Parameters for transaction preparationPreparedTransaction<T>- Prepared transaction with gas estimates
State Stores
OndoGMState.baseState- Global application state store
Type Definitions
The package exports comprehensive TypeScript types for all Ondo protocol entities, generated from the OpenAPI specification.
import type { Account, Asset, Attestation, Market, OHLCData } from '@leapwallet/ondo-gm-core';Integration with Other Packages
This core package is designed to work seamlessly with other packages in the Ondo SDK:
- @leapwallet/ondo-gm-react-adapter - React hooks and providers
- @leapwallet/ondo-gm-evm-client - EVM blockchain client
- @leapwallet/ondo-gm-react-ui - Pre-built UI components
Dependencies
@tanstack/query-core- Query state managementmobx- Reactive state management
License
ISC
