@pear-protocol/hyperliquid-sdk 0.0.56 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/agentWallet.d.ts +2 -2
- package/dist/clients/notifications.d.ts +2 -2
- package/dist/clients/orders.d.ts +3 -3
- package/dist/clients/portfolio.d.ts +2 -2
- package/dist/clients/positions.d.ts +7 -7
- package/dist/clients/sync.d.ts +2 -2
- package/dist/clients/watchlist.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAuth.d.ts +12 -0
- package/dist/hooks/useAutoSyncFills.d.ts +0 -2
- package/dist/index.d.ts +76 -75
- package/dist/index.js +4115 -4002
- package/dist/provider.d.ts +1 -29
- package/dist/types.d.ts +1 -7
- package/dist/utils/http.d.ts +23 -0
- package/package.json +1 -1
package/dist/provider.d.ts
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import type { UserProfile } from './types';
|
|
3
|
-
import { AuthStatus } from './types';
|
|
4
2
|
export interface PearHyperliquidContextType {
|
|
3
|
+
clientId: string;
|
|
5
4
|
apiBaseUrl: string;
|
|
6
5
|
wsUrl: string;
|
|
7
|
-
address: string | null;
|
|
8
|
-
setAddress: (address: string | null) => void;
|
|
9
6
|
isConnected: boolean;
|
|
10
7
|
lastError: string | null;
|
|
11
8
|
nativeIsConnected: boolean;
|
|
12
9
|
nativeLastError: string | null;
|
|
13
|
-
authStatus: AuthStatus;
|
|
14
|
-
isAuthenticated: boolean;
|
|
15
|
-
accessToken: string | null;
|
|
16
|
-
user: UserProfile | null;
|
|
17
|
-
authError: string | null;
|
|
18
|
-
getEip712: (address: string) => Promise<any>;
|
|
19
|
-
loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
20
|
-
loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
|
|
21
|
-
refreshTokens: () => Promise<any>;
|
|
22
|
-
logout: () => Promise<void>;
|
|
23
10
|
}
|
|
24
11
|
export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
|
|
25
12
|
interface PearHyperliquidProviderProps {
|
|
@@ -37,19 +24,4 @@ export declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderPr
|
|
|
37
24
|
* Prefer using the more specific hooks below when possible.
|
|
38
25
|
*/
|
|
39
26
|
export declare function usePearHyperliquid(): PearHyperliquidContextType;
|
|
40
|
-
/**
|
|
41
|
-
* Provider-aware Auth hook. Uses auth state/actions provided by PearHyperliquidProvider.
|
|
42
|
-
* Callers do not need to pass baseUrl/clientId.
|
|
43
|
-
*/
|
|
44
|
-
export declare function usePearAuth(): {
|
|
45
|
-
readonly status: AuthStatus;
|
|
46
|
-
readonly isAuthenticated: boolean;
|
|
47
|
-
readonly user: UserProfile | null;
|
|
48
|
-
readonly error: string | null;
|
|
49
|
-
readonly getEip712: (address: string) => Promise<any>;
|
|
50
|
-
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
51
|
-
readonly loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
|
|
52
|
-
readonly refreshTokens: () => Promise<any>;
|
|
53
|
-
readonly logout: () => Promise<void>;
|
|
54
|
-
};
|
|
55
27
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -338,12 +338,6 @@ export interface AddressState {
|
|
|
338
338
|
autoConnect: boolean;
|
|
339
339
|
previousAddresses: string[];
|
|
340
340
|
}
|
|
341
|
-
export declare enum AuthStatus {
|
|
342
|
-
Idle = "idle",
|
|
343
|
-
Authenticating = "authenticating",
|
|
344
|
-
Authenticated = "authenticated",
|
|
345
|
-
Error = "error"
|
|
346
|
-
}
|
|
347
341
|
export interface UseAuthOptions {
|
|
348
342
|
baseUrl: string;
|
|
349
343
|
clientId: string;
|
|
@@ -359,7 +353,7 @@ export interface EIP712AuthDetails {
|
|
|
359
353
|
name: string;
|
|
360
354
|
version: string;
|
|
361
355
|
chainId: number;
|
|
362
|
-
verifyingContract: string
|
|
356
|
+
verifyingContract: `0x${string}`;
|
|
363
357
|
};
|
|
364
358
|
types: Record<string, Array<{
|
|
365
359
|
name: string;
|
package/dist/utils/http.d.ts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
1
2
|
import { ApiErrorResponse } from '../types';
|
|
2
3
|
export declare function toApiError(error: unknown): ApiErrorResponse;
|
|
3
4
|
export declare function joinUrl(baseUrl: string, path: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Shared Axios instance with interceptors.
|
|
7
|
+
* - Request: inject Authorization headers from buildAuthHeaders when absent
|
|
8
|
+
* - Response: on 401, clear tokens and emit a logout event
|
|
9
|
+
*/
|
|
10
|
+
export declare const apiClient: AxiosInstance;
|
|
11
|
+
/**
|
|
12
|
+
* Attach auth-aware Axios interceptors to `apiClient`.
|
|
13
|
+
* - Request: adds `Authorization: Bearer <accessToken>` for requests to `apiBaseUrl`.
|
|
14
|
+
* - Response: if a request returns 401, attempts token refresh and retries the request.
|
|
15
|
+
* If the 401 came from the refresh endpoint (or refresh fails/returns 401), calls `logout()`.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export declare function addAuthInterceptors(params: {
|
|
19
|
+
apiBaseUrl: string;
|
|
20
|
+
getAccessToken: () => string | null;
|
|
21
|
+
refreshTokens: () => Promise<{
|
|
22
|
+
accessToken: string;
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
} | any>;
|
|
25
|
+
logout: () => Promise<void> | void;
|
|
26
|
+
}): () => void;
|