@agg-build/hooks 2.1.1 → 2.1.3

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/deposit.js CHANGED
@@ -92,16 +92,18 @@ function normalizeWalletError(error, supportedChains) {
92
92
 
93
93
  // src/deposit/use-wallet-token-balance.ts
94
94
  var import_web32 = require("@solana/web3.js");
95
- var import_react_query = require("@tanstack/react-query");
95
+ var import_react_query2 = require("@tanstack/react-query");
96
96
  var import_viem = require("viem");
97
97
  var import_wagmi = require("wagmi");
98
98
 
99
99
  // src/deposit/constants.ts
100
100
  var DEFAULT_SOLANA_RPC_ENDPOINTS = [
101
+ "https://solana-mainnet.g.alchemy.com/v2",
102
+ "https://solana-rpc.publicnode.com",
101
103
  "https://api.mainnet.solana.com",
102
- "https://solana-rpc.publicnode.com"
104
+ "https://rpc.ankr.com/solana"
103
105
  ];
104
- var DEFAULT_SOLANA_RPC_ENDPOINT = DEFAULT_SOLANA_RPC_ENDPOINTS[0];
106
+ var DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
105
107
  var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
106
108
  var MULTI_CHAIN_SOLANA_WALLET_NAMES = /* @__PURE__ */ new Set(["Phantom"]);
107
109
 
@@ -136,6 +138,7 @@ function useSvmAddress() {
136
138
  // src/deposit/svm-connections.ts
137
139
  var import_web3 = require("@solana/web3.js");
138
140
  var import_react4 = require("react");
141
+ var import_react_query = require("@tanstack/react-query");
139
142
 
140
143
  // src/core/providers/contexts.ts
141
144
  var import_react2 = require("react");
@@ -596,6 +599,8 @@ var enUsLabels = {
596
599
  showOutcomeAria: (label) => `Show ${label} outcome`,
597
600
  viewResolved: "View resolved",
598
601
  hideResolved: "Hide resolved",
602
+ resolvingTitle: "Resolving market\u2026",
603
+ resolvingDescription: "This market has closed. We're waiting for final settlement data and will update the result once it's confirmed on-chain.",
599
604
  volumeUnavailable: "Volume unavailable",
600
605
  tabs: {
601
606
  orderBook: "Order Book",
@@ -769,6 +774,7 @@ var enUsLabels = {
769
774
  orderSkip: "Skip",
770
775
  orderRetryRemaining: "Retry remaining",
771
776
  resolvedEarningsTitle: "Your Earnings",
777
+ resolvedResolutionDateLabel: "Resolution date",
772
778
  resolvedSharesLabel: "Shares",
773
779
  resolvedTotalPayoutLabel: "Total payout",
774
780
  claimWinnings: "Claim Winnings",
@@ -913,7 +919,51 @@ var enUsLabels = {
913
919
  winningOutcome: (label) => `Winning outcome: ${label}`,
914
920
  resolvedOutcome: (label) => `Resolved: ${label}`,
915
921
  marketDetailsAriaByDate: (dateLabel) => `Market details for ${dateLabel}`,
916
- marketDetailsAriaByQuestion: (question) => `Market details for ${question}`
922
+ marketDetailsAriaByQuestion: (question) => `Market details for ${question}`,
923
+ sports: {
924
+ summaryAria: "Sports event summary",
925
+ sectionTabsAria: "Sports market sections",
926
+ lineSelectorAria: (marketTitle) => `Select line for ${marketTitle}`,
927
+ previousLineAria: (marketTitle) => `Show previous lines for ${marketTitle}`,
928
+ nextLineAria: (marketTitle) => `Show next lines for ${marketTitle}`,
929
+ comparisonToggleAria: (marketTitle, expanded) => `${expanded ? "Hide" : "Show"} venue comparison for ${marketTitle}`,
930
+ comparisonTitle: "Venue alternatives",
931
+ compareVenues: (count) => `Compare ${count} venues`,
932
+ marketCount: (count) => `${count} markets`,
933
+ venueCount: (count) => `${count} venues`,
934
+ volumeShort: "Vol.",
935
+ totalVolumeShort: "Total Vol.",
936
+ gameStarts: "Game starts",
937
+ moreMarketsTitle: "More markets",
938
+ gameLinesTab: "Game Lines",
939
+ halvesTab: "Halves",
940
+ exactScoreTab: "Exact Score",
941
+ cornersTab: "Corners",
942
+ goalsTab: "Goals",
943
+ assistsTab: "Assists",
944
+ shotsTab: "Shots",
945
+ otherTab: "Other",
946
+ moneylineTitle: "Moneyline",
947
+ spreadTitle: "Spreads",
948
+ totalTitle: "Totals",
949
+ fullPeriod: "Regular time",
950
+ firstHalfPeriod: "1st half",
951
+ secondHalfPeriod: "2nd half",
952
+ quarterOnePeriod: "1st quarter",
953
+ quarterTwoPeriod: "2nd quarter",
954
+ quarterThreePeriod: "3rd quarter",
955
+ quarterFourPeriod: "4th quarter",
956
+ overtimePeriod: "Overtime",
957
+ otherPeriod: "Other",
958
+ loadingTitle: "Loading section",
959
+ loadingDescription: "Fetching the latest markets for this game.",
960
+ emptyTitle: "No markets available",
961
+ emptyDescription: (sectionLabel) => `There are no ${sectionLabel} markets yet.`,
962
+ loadMore: "Load more",
963
+ loadingMore: "Loading more",
964
+ bestPriceBadge: "Best price",
965
+ selectOutcomeAria: (marketTitle, outcomeLabel, priceLabel) => `Select ${outcomeLabel} in ${marketTitle} at ${priceLabel}`
966
+ }
917
967
  },
918
968
  header: {
919
969
  bannerAria: "Site header",
@@ -1055,7 +1105,8 @@ var defaultAggUiConfig = {
1055
1105
  showFeesBreakdown: false,
1056
1106
  enableGradients: false,
1057
1107
  enableVenueEventDiscoveryFilters: false,
1058
- enableNotifications: true
1108
+ enableNotifications: true,
1109
+ showSportsMarkets: false
1059
1110
  },
1060
1111
  market: {
1061
1112
  arbitrageThreshold: 0,
@@ -1168,6 +1219,9 @@ var useAggClient = () => {
1168
1219
  }
1169
1220
  return client;
1170
1221
  };
1222
+ var useOptionalAggClient = () => {
1223
+ return (0, import_react3.useContext)(AggClientContext);
1224
+ };
1171
1225
  var useAggUiConfig = () => {
1172
1226
  return (0, import_react3.useContext)(AggUiContext);
1173
1227
  };
@@ -1203,10 +1257,28 @@ function resolveSvmRpcEndpoints(partnerUrl) {
1203
1257
  }
1204
1258
  function useSvmConnections(commitment) {
1205
1259
  const { solanaRpcUrl } = useAggUiConfig();
1260
+ const client = useOptionalAggClient();
1261
+ const { data: tokenData } = (0, import_react_query.useQuery)({
1262
+ queryKey: ["alchemy-rpc-token"],
1263
+ queryFn: () => client ? client.getRpcToken() : Promise.resolve({ token: "", expiresAt: 0 }),
1264
+ enabled: !!client,
1265
+ staleTime: 50 * 60 * 1e3
1266
+ // 50 minutes cache (token is valid for 1h)
1267
+ });
1268
+ const token = tokenData == null ? void 0 : tokenData.token;
1206
1269
  return (0, import_react4.useMemo)(() => {
1207
1270
  const endpoints = resolveSvmRpcEndpoints(solanaRpcUrl);
1208
- return endpoints.map((url) => new import_web3.Connection(url, commitment));
1209
- }, [solanaRpcUrl, commitment]);
1271
+ return endpoints.map((url) => {
1272
+ const headers = {};
1273
+ if (url.includes("alchemy.com") && token) {
1274
+ headers["Authorization"] = `Bearer ${token}`;
1275
+ }
1276
+ return new import_web3.Connection(url, {
1277
+ commitment,
1278
+ httpHeaders: Object.keys(headers).length > 0 ? headers : void 0
1279
+ });
1280
+ });
1281
+ }, [solanaRpcUrl, commitment, token]);
1210
1282
  }
1211
1283
  function withSvmFailover(connections, operation) {
1212
1284
  return __async(this, null, function* () {
@@ -1301,7 +1373,7 @@ function useWalletTokenBalance({
1301
1373
  const resolvedSvmAddress = detectedSvmAddress != null ? detectedSvmAddress : svmAddress;
1302
1374
  const svmEnabled = isOpen && isSvm && !!resolvedSvmAddress && !!tokenAddress;
1303
1375
  const svmConnections = useSvmConnections();
1304
- const svmQuery = (0, import_react_query.useQuery)({
1376
+ const svmQuery = (0, import_react_query2.useQuery)({
1305
1377
  queryKey: ["svm-token-balance", resolvedSvmAddress != null ? resolvedSvmAddress : null, tokenAddress != null ? tokenAddress : null, isOpen],
1306
1378
  enabled: svmEnabled,
1307
1379
  staleTime: SVM_BALANCE_STALE_TIME_MS,
@@ -1517,7 +1589,7 @@ function useWalletSendToken() {
1517
1589
  }
1518
1590
 
1519
1591
  // src/deposit/use-wallet-transaction-status.ts
1520
- var import_react_query2 = require("@tanstack/react-query");
1592
+ var import_react_query3 = require("@tanstack/react-query");
1521
1593
  var import_viem3 = require("viem");
1522
1594
  var import_wagmi3 = require("wagmi");
1523
1595
  function useWalletTransactionStatus({
@@ -1536,7 +1608,7 @@ function useWalletTransactionStatus({
1536
1608
  }
1537
1609
  });
1538
1610
  const svmConnections = useSvmConnections("confirmed");
1539
- const svmQuery = (0, import_react_query2.useQuery)({
1611
+ const svmQuery = (0, import_react_query3.useQuery)({
1540
1612
  queryKey: ["wallet-transaction-status", chainId != null ? chainId : null, txId != null ? txId : null],
1541
1613
  enabled: isSvm && !!txId,
1542
1614
  refetchInterval: (query) => query.state.data === "settled" || query.state.data === "error" ? false : 2e3,
@@ -1580,7 +1652,7 @@ var import_wallet_adapter_react3 = require("@solana/wallet-adapter-react");
1580
1652
 
1581
1653
  // src/execution/use-deposit-addresses.ts
1582
1654
  var import_react6 = require("react");
1583
- var import_react_query3 = require("@tanstack/react-query");
1655
+ var import_react_query4 = require("@tanstack/react-query");
1584
1656
  var SVM_CHAIN_IDS2 = /* @__PURE__ */ new Set([792703809]);
1585
1657
  function getDepositAddress(chainId, data) {
1586
1658
  return chainId !== void 0 && SVM_CHAIN_IDS2.has(chainId) ? data.svmAddress : data.evmAddress;
@@ -1604,7 +1676,7 @@ function useDepositAddresses(options) {
1604
1676
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
1605
1677
  };
1606
1678
  }, [enabled, poll, timeoutMs]);
1607
- const query = (0, import_react_query3.useQuery)({
1679
+ const query = (0, import_react_query4.useQuery)({
1608
1680
  queryKey: executionKeys.depositAddresses(),
1609
1681
  queryFn: () => client.getDepositAddresses(),
1610
1682
  enabled,
@@ -1636,11 +1708,11 @@ function useDepositAddresses(options) {
1636
1708
  }
1637
1709
 
1638
1710
  // src/execution/use-sync-balances.ts
1639
- var import_react_query4 = require("@tanstack/react-query");
1711
+ var import_react_query5 = require("@tanstack/react-query");
1640
1712
  function useSyncBalances(options) {
1641
1713
  const client = useAggClient();
1642
- const queryClient = (0, import_react_query4.useQueryClient)();
1643
- return (0, import_react_query4.useMutation)({
1714
+ const queryClient = (0, import_react_query5.useQueryClient)();
1715
+ return (0, import_react_query5.useMutation)({
1644
1716
  mutationFn: () => client.syncManagedBalances(),
1645
1717
  onSuccess: () => {
1646
1718
  var _a;
@@ -1652,10 +1724,10 @@ function useSyncBalances(options) {
1652
1724
  }
1653
1725
 
1654
1726
  // src/use-ramp-quotes.ts
1655
- var import_react_query5 = require("@tanstack/react-query");
1727
+ var import_react_query6 = require("@tanstack/react-query");
1656
1728
  function useRampQuotes() {
1657
1729
  const client = useAggClient();
1658
- return (0, import_react_query5.useMutation)({
1730
+ return (0, import_react_query6.useMutation)({
1659
1731
  mutationFn: (params) => __async(null, null, function* () {
1660
1732
  return client.getRampQuotes(params);
1661
1733
  })
@@ -1663,10 +1735,10 @@ function useRampQuotes() {
1663
1735
  }
1664
1736
 
1665
1737
  // src/use-ramp-session.ts
1666
- var import_react_query6 = require("@tanstack/react-query");
1738
+ var import_react_query7 = require("@tanstack/react-query");
1667
1739
  function useRampSession() {
1668
1740
  const client = useAggClient();
1669
- return (0, import_react_query6.useMutation)({
1741
+ return (0, import_react_query7.useMutation)({
1670
1742
  mutationFn: (params) => __async(null, null, function* () {
1671
1743
  return client.createRampSession(params);
1672
1744
  })
package/dist/deposit.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useRampQuotes,
3
3
  useRampSession
4
- } from "./chunk-AFZD3GIQ.mjs";
4
+ } from "./chunk-SN4AO5D7.mjs";
5
5
  import {
6
6
  __async,
7
7
  useAggAuthState,
@@ -9,8 +9,9 @@ import {
9
9
  useAggClient,
10
10
  useAggUiConfig,
11
11
  useDepositAddresses,
12
+ useOptionalAggClient,
12
13
  useSyncBalances
13
- } from "./chunk-FYEPQHKO.mjs";
14
+ } from "./chunk-56RISN73.mjs";
14
15
 
15
16
  // src/deposit/normalize-wallet-error.ts
16
17
  function normalizeWalletError(error, supportedChains) {
@@ -35,16 +36,18 @@ function normalizeWalletError(error, supportedChains) {
35
36
 
36
37
  // src/deposit/use-wallet-token-balance.ts
37
38
  import { PublicKey } from "@solana/web3.js";
38
- import { useQuery } from "@tanstack/react-query";
39
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
39
40
  import { formatUnits } from "viem";
40
41
  import { useAccount, useReadContract } from "wagmi";
41
42
 
42
43
  // src/deposit/constants.ts
43
44
  var DEFAULT_SOLANA_RPC_ENDPOINTS = [
45
+ "https://solana-mainnet.g.alchemy.com/v2",
46
+ "https://solana-rpc.publicnode.com",
44
47
  "https://api.mainnet.solana.com",
45
- "https://solana-rpc.publicnode.com"
48
+ "https://rpc.ankr.com/solana"
46
49
  ];
47
- var DEFAULT_SOLANA_RPC_ENDPOINT = DEFAULT_SOLANA_RPC_ENDPOINTS[0];
50
+ var DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
48
51
  var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
49
52
  var MULTI_CHAIN_SOLANA_WALLET_NAMES = /* @__PURE__ */ new Set(["Phantom"]);
50
53
 
@@ -79,6 +82,7 @@ function useSvmAddress() {
79
82
  // src/deposit/svm-connections.ts
80
83
  import { Connection } from "@solana/web3.js";
81
84
  import { useMemo } from "react";
85
+ import { useQuery } from "@tanstack/react-query";
82
86
  function resolveSvmRpcEndpoints(partnerUrl) {
83
87
  const seen = /* @__PURE__ */ new Set();
84
88
  const out = [];
@@ -93,10 +97,28 @@ function resolveSvmRpcEndpoints(partnerUrl) {
93
97
  }
94
98
  function useSvmConnections(commitment) {
95
99
  const { solanaRpcUrl } = useAggUiConfig();
100
+ const client = useOptionalAggClient();
101
+ const { data: tokenData } = useQuery({
102
+ queryKey: ["alchemy-rpc-token"],
103
+ queryFn: () => client ? client.getRpcToken() : Promise.resolve({ token: "", expiresAt: 0 }),
104
+ enabled: !!client,
105
+ staleTime: 50 * 60 * 1e3
106
+ // 50 minutes cache (token is valid for 1h)
107
+ });
108
+ const token = tokenData == null ? void 0 : tokenData.token;
96
109
  return useMemo(() => {
97
110
  const endpoints = resolveSvmRpcEndpoints(solanaRpcUrl);
98
- return endpoints.map((url) => new Connection(url, commitment));
99
- }, [solanaRpcUrl, commitment]);
111
+ return endpoints.map((url) => {
112
+ const headers = {};
113
+ if (url.includes("alchemy.com") && token) {
114
+ headers["Authorization"] = `Bearer ${token}`;
115
+ }
116
+ return new Connection(url, {
117
+ commitment,
118
+ httpHeaders: Object.keys(headers).length > 0 ? headers : void 0
119
+ });
120
+ });
121
+ }, [solanaRpcUrl, commitment, token]);
100
122
  }
101
123
  function withSvmFailover(connections, operation) {
102
124
  return __async(this, null, function* () {
@@ -191,7 +213,7 @@ function useWalletTokenBalance({
191
213
  const resolvedSvmAddress = detectedSvmAddress != null ? detectedSvmAddress : svmAddress;
192
214
  const svmEnabled = isOpen && isSvm && !!resolvedSvmAddress && !!tokenAddress;
193
215
  const svmConnections = useSvmConnections();
194
- const svmQuery = useQuery({
216
+ const svmQuery = useQuery2({
195
217
  queryKey: ["svm-token-balance", resolvedSvmAddress != null ? resolvedSvmAddress : null, tokenAddress != null ? tokenAddress : null, isOpen],
196
218
  enabled: svmEnabled,
197
219
  staleTime: SVM_BALANCE_STALE_TIME_MS,
@@ -413,7 +435,7 @@ function useWalletSendToken() {
413
435
  }
414
436
 
415
437
  // src/deposit/use-wallet-transaction-status.ts
416
- import { useQuery as useQuery2 } from "@tanstack/react-query";
438
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
417
439
  import { formatEther } from "viem";
418
440
  import { useWaitForTransactionReceipt } from "wagmi";
419
441
  function useWalletTransactionStatus({
@@ -432,7 +454,7 @@ function useWalletTransactionStatus({
432
454
  }
433
455
  });
434
456
  const svmConnections = useSvmConnections("confirmed");
435
- const svmQuery = useQuery2({
457
+ const svmQuery = useQuery3({
436
458
  queryKey: ["wallet-transaction-status", chainId != null ? chainId : null, txId != null ? txId : null],
437
459
  enabled: isSvm && !!txId,
438
460
  refetchInterval: (query) => query.state.data === "settled" || query.state.data === "error" ? false : 2e3,