@pear-protocol/hyperliquid-sdk
Version:
React SDK for Pear Protocol Hyperliquid API integration
56 lines (55 loc) • 2.17 kB
TypeScript
import React, { ReactNode } from 'react';
import type { UserProfile } from './types';
import { AuthStatus } from './types';
export interface PearHyperliquidContextType {
apiBaseUrl: string;
wsUrl: string;
address: string | null;
setAddress: (address: string | null) => void;
isConnected: boolean;
lastError: string | null;
nativeIsConnected: boolean;
nativeLastError: string | null;
authStatus: AuthStatus;
isAuthenticated: boolean;
accessToken: string | null;
user: UserProfile | null;
authError: string | null;
getEip712: (address: string) => Promise<any>;
loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
refreshTokens: () => Promise<any>;
logout: () => Promise<void>;
}
export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
interface PearHyperliquidProviderProps {
children: ReactNode;
apiBaseUrl?: string;
clientId?: string;
wsUrl?: string;
}
/**
* React Provider for PearHyperliquidClient
*/
export declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderProps>;
/**
* Hook to access the entire Pear Hyperliquid context.
* Prefer using the more specific hooks below when possible.
*/
export declare function usePearHyperliquid(): PearHyperliquidContextType;
/**
* Provider-aware Auth hook. Uses auth state/actions provided by PearHyperliquidProvider.
* Callers do not need to pass baseUrl/clientId.
*/
export declare function usePearAuth(): {
readonly status: AuthStatus;
readonly isAuthenticated: boolean;
readonly user: UserProfile | null;
readonly error: string | null;
readonly getEip712: (address: string) => Promise<any>;
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
readonly loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
readonly refreshTokens: () => Promise<any>;
readonly logout: () => Promise<void>;
};
export {};