@pear-protocol/symmio-client 0.2.9 → 0.2.10

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.
@@ -62,11 +62,14 @@ var useSymmWsStore = create((set) => ({
62
62
  function asUnsubscribeFn(value) {
63
63
  return typeof value === "function" ? value : null;
64
64
  }
65
- function useSymmWs(params) {
65
+ function useSymmWs(params = {}) {
66
+ const { symmCoreClient: ctxClient, address: ctxAddress, chainId: ctxChainId } = useSymmContext();
66
67
  const queryClient = useQueryClient();
67
68
  const isConnected = useSymmWsStore((state) => state.isConnected);
68
69
  const setConnected = useSymmWsStore((state) => state.setConnected);
69
- const { symmCoreClient, accountAddress, chainId } = params;
70
+ const symmCoreClient = params.symmCoreClient ?? ctxClient;
71
+ const accountAddress = params.accountAddress ?? ctxAddress;
72
+ const chainId = params.chainId ?? ctxChainId;
70
73
  useEffect(() => {
71
74
  if (!symmCoreClient || !accountAddress) {
72
75
  setConnected(false);
@@ -393,10 +396,17 @@ var useSymmAuthStore = create((set, get) => ({
393
396
 
394
397
  // src/react/hooks/use-symm-auth.ts
395
398
  function useSymmAuth(params) {
396
- const { address, chainId, walletClient, siweDomain } = params;
397
- const accessToken = useSymmAuthStore(
398
- (state) => address ? state.tokensByKey[symmAuthTokenKey(address, chainId)] ?? null : null
399
- );
399
+ const ctx = useSymmContext();
400
+ const address = params?.address ?? ctx.address;
401
+ const chainId = params?.chainId ?? ctx.chainId ?? 42161;
402
+ const walletClient = params?.walletClient ?? ctx.walletClient;
403
+ const siweDomain = params?.siweDomain;
404
+ const accessToken = useSymmAuthStore((state) => {
405
+ if (address) {
406
+ return state.tokensByKey[symmAuthTokenKey(address, chainId)] ?? null;
407
+ }
408
+ return ctx.accessToken ?? ctx.authToken ?? null;
409
+ });
400
410
  const setToken = useSymmAuthStore((state) => state.setToken);
401
411
  const getToken = useSymmAuthStore((state) => state.getToken);
402
412
  const clearToken = useSymmAuthStore((state) => state.clearToken);
@@ -1187,7 +1197,7 @@ async function getAccounts(publicClient, multiAccount, user, start = 0, size = 1
1187
1197
 
1188
1198
  // src/react/hooks/use-symm-accounts.ts
1189
1199
  var EMPTY_ACCOUNTS = [];
1190
- function useSymmAccounts(params, options) {
1200
+ function useSymmAccounts(params = {}, options) {
1191
1201
  const { chainId, symmioConfig } = useSymmContext();
1192
1202
  const { userAddress, publicClient, walletClient } = params;
1193
1203
  const queryClient = useQueryClient();
@@ -1562,7 +1572,7 @@ async function depositAndAllocate(walletClient, publicClient, multiAccount, para
1562
1572
  }
1563
1573
 
1564
1574
  // src/react/hooks/use-symm-deposit.ts
1565
- function useSymmDeposit(params) {
1575
+ function useSymmDeposit(params = {}) {
1566
1576
  const { chainId, symmioConfig } = useSymmContext();
1567
1577
  const { publicClient, walletClient } = params;
1568
1578
  const queryClient = useQueryClient();
@@ -1622,7 +1632,7 @@ async function withdraw(walletClient, publicClient, multiAccount, params) {
1622
1632
  }
1623
1633
 
1624
1634
  // src/react/hooks/use-symm-withdraw.ts
1625
- function useSymmWithdraw(params) {
1635
+ function useSymmWithdraw(params = {}) {
1626
1636
  const { chainId, symmioConfig } = useSymmContext();
1627
1637
  const { publicClient, walletClient } = params;
1628
1638
  const queryClient = useQueryClient();
@@ -24290,7 +24300,7 @@ var MuonClient = class {
24290
24300
  };
24291
24301
 
24292
24302
  // src/react/hooks/use-symm-collateral.ts
24293
- function useSymmCollateral(params) {
24303
+ function useSymmCollateral(params = {}) {
24294
24304
  const { chainId, symmioConfig } = useSymmContext();
24295
24305
  const { publicClient, walletClient } = params;
24296
24306
  const queryClient = useQueryClient();
@@ -24443,7 +24453,7 @@ async function hasSignedCurrentVersion(publicClient, signatureStore, user) {
24443
24453
  }
24444
24454
 
24445
24455
  // src/react/hooks/use-symm-signature.ts
24446
- function useSymmSignature(params, options) {
24456
+ function useSymmSignature(params = {}, options) {
24447
24457
  const { chainId, symmioConfig } = useSymmContext();
24448
24458
  const { userAddress, publicClient, walletClient } = params;
24449
24459
  const queryClient = useQueryClient();
@@ -24676,6 +24686,13 @@ function useSymmPositions(params) {
24676
24686
  const resolvedAddress = accountAddress ? void 0 : address;
24677
24687
  const chainId = params.chainId ?? ctxChainId;
24678
24688
  const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
24689
+ console.log({
24690
+ symmCoreClient,
24691
+ accountAddress,
24692
+ resolvedAddress,
24693
+ chainId,
24694
+ internalEnabled
24695
+ });
24679
24696
  const query = useQuery({
24680
24697
  ...params.query,
24681
24698
  queryKey: symmKeys.positions({
@@ -24930,10 +24947,11 @@ function useSymmMarkets(params) {
24930
24947
  ...params?.query,
24931
24948
  queryKey: symmKeys.markets(chainId, searchText),
24932
24949
  queryFn: () => {
24950
+ const marketsApi = symmCoreClient.markets;
24933
24951
  if (searchText) {
24934
- return symmCoreClient.markets.search(searchText);
24952
+ return marketsApi.search(searchText, chainId);
24935
24953
  }
24936
- return symmCoreClient.markets.list({ pageSize: "500" });
24954
+ return marketsApi.list({ pageSize: "500", chainId });
24937
24955
  },
24938
24956
  enabled: internalEnabled && (params?.query?.enabled ?? true)
24939
24957
  });