@pear-protocol/hyperliquid-sdk 0.1.26 → 0.1.28

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.
@@ -5,8 +5,8 @@ export declare function useAuth(): {
5
5
  readonly address: string | null;
6
6
  readonly accessToken: string | null;
7
7
  readonly refreshToken: string | null;
8
- readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
9
- readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
8
+ readonly getEip712: (address: string, chainId?: number) => Promise<GetEIP712MessageResponse>;
9
+ readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number, chainId?: number) => Promise<void>;
10
10
  readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
11
11
  readonly refreshTokens: () => Promise<import("../types").RefreshTokenResponse>;
12
12
  readonly logout: () => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1472,8 +1472,8 @@ declare function useAuth(): {
1472
1472
  readonly address: string | null;
1473
1473
  readonly accessToken: string | null;
1474
1474
  readonly refreshToken: string | null;
1475
- readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
1476
- readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
1475
+ readonly getEip712: (address: string, chainId?: number) => Promise<GetEIP712MessageResponse>;
1476
+ readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number, chainId?: number) => Promise<void>;
1477
1477
  readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
1478
1478
  readonly refreshTokens: () => Promise<RefreshTokenResponse>;
1479
1479
  readonly logout: () => Promise<void>;
package/dist/index.js CHANGED
@@ -820,22 +820,13 @@ function validateClosePositionRequest(payload) {
820
820
  }
821
821
 
822
822
  const DEFAULT_STATE = {
823
- longTokens: [
824
- { symbol: "HYPE", weight: 25 },
825
- { symbol: "BTC", weight: 25 },
826
- ],
827
- shortTokens: [
828
- { symbol: "AVAX", weight: 10 },
829
- { symbol: "SEI", weight: 10 },
830
- { symbol: "ADA", weight: 10 },
831
- { symbol: "TRUMP", weight: 10 },
832
- { symbol: "SUI", weight: 10 },
833
- ],
823
+ longTokens: [],
824
+ shortTokens: [],
834
825
  openTokenSelector: false,
835
826
  selectorConfig: null,
836
827
  openConflictModal: false,
837
828
  conflicts: [],
838
- candleInterval: "1h",
829
+ candleInterval: '1h',
839
830
  isWeightBalanced: true,
840
831
  };
841
832
  const useUserSelection$1 = create((set, get) => ({
@@ -855,7 +846,11 @@ const useUserSelection$1 = create((set, get) => ({
855
846
  const longTotal = updated.reduce((sum, t) => sum + t.weight, 0);
856
847
  const shortTotal = prev.shortTokens.reduce((sum, t) => sum + t.weight, 0);
857
848
  const isWeightBalanced = longTotal + shortTotal === 100;
858
- return { ...prev, longTokens: updated, isWeightBalanced };
849
+ return {
850
+ ...prev,
851
+ longTokens: updated,
852
+ isWeightBalanced,
853
+ };
859
854
  }
860
855
  else {
861
856
  const updated = [...prev.shortTokens];
@@ -863,7 +858,11 @@ const useUserSelection$1 = create((set, get) => ({
863
858
  const longTotal = prev.longTokens.reduce((sum, t) => sum + t.weight, 0);
864
859
  const shortTotal = updated.reduce((sum, t) => sum + t.weight, 0);
865
860
  const isWeightBalanced = longTotal + shortTotal === 100;
866
- return { ...prev, shortTokens: updated, isWeightBalanced };
861
+ return {
862
+ ...prev,
863
+ shortTokens: updated,
864
+ isWeightBalanced,
865
+ };
867
866
  }
868
867
  });
869
868
  },
@@ -892,14 +891,22 @@ const useUserSelection$1 = create((set, get) => ({
892
891
  const longTotal = updated.reduce((sum, t) => sum + t.weight, 0);
893
892
  const shortTotal = prev.shortTokens.reduce((sum, t) => sum + t.weight, 0);
894
893
  const isWeightBalanced = longTotal + shortTotal === 100;
895
- return { ...prev, longTokens: updated, isWeightBalanced };
894
+ return {
895
+ ...prev,
896
+ longTokens: updated,
897
+ isWeightBalanced,
898
+ };
896
899
  }
897
900
  else {
898
901
  const updated = prev.shortTokens.filter((_, i) => i !== index);
899
902
  const longTotal = prev.longTokens.reduce((sum, t) => sum + t.weight, 0);
900
903
  const shortTotal = updated.reduce((sum, t) => sum + t.weight, 0);
901
904
  const isWeightBalanced = longTotal + shortTotal === 100;
902
- return { ...prev, shortTokens: updated, isWeightBalanced };
905
+ return {
906
+ ...prev,
907
+ shortTokens: updated,
908
+ isWeightBalanced,
909
+ };
903
910
  }
904
911
  });
905
912
  },
@@ -8048,17 +8055,17 @@ function useAuth() {
8048
8055
  clearTimeout(timer);
8049
8056
  };
8050
8057
  }, [address, refreshToken$1]);
8051
- async function getEip712(address) {
8052
- const { data } = await getEIP712Message(apiBaseUrl, address, clientId);
8058
+ async function getEip712(address, chainId) {
8059
+ const { data } = await getEIP712Message(apiBaseUrl, address, clientId, chainId);
8053
8060
  return data;
8054
8061
  }
8055
- async function loginWithSignedMessage(address, signature, timestamp) {
8062
+ async function loginWithSignedMessage(address, signature, timestamp, chainId) {
8056
8063
  try {
8057
8064
  const { data } = await authenticate(apiBaseUrl, {
8058
8065
  method: 'eip712',
8059
8066
  address,
8060
8067
  clientId,
8061
- details: { signature, timestamp },
8068
+ details: { signature, timestamp, chainId },
8062
8069
  });
8063
8070
  const accessTokenKey = `${address}_accessToken`;
8064
8071
  const refreshTokenKey = `${address}_refreshToken`;
@@ -1,4 +1,4 @@
1
- import type { CandleInterval, TokenConflict, TokenSelection, TokenSelectorConfig } from "../types";
1
+ import type { CandleInterval, TokenConflict, TokenSelection, TokenSelectorConfig } from '../types';
2
2
  interface UserSelectionState {
3
3
  longTokens: TokenSelection[];
4
4
  shortTokens: TokenSelection[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",