@agg-build/hooks 1.2.0 → 1.2.12

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
@@ -91,23 +91,10 @@ function normalizeWalletError(error, supportedChains) {
91
91
  }
92
92
 
93
93
  // src/deposit/use-wallet-token-balance.ts
94
- var import_react3 = require("react");
94
+ var import_web3 = require("@solana/web3.js");
95
95
  var import_react_query = require("@tanstack/react-query");
96
96
  var import_viem = require("viem");
97
97
  var import_wagmi = require("wagmi");
98
- var import_wallet_adapter_react = require("@solana/wallet-adapter-react");
99
- var import_web3 = require("@solana/web3.js");
100
-
101
- // ../common/src/utils/auth.ts
102
- function getWalletAddressFromUserProfile(user) {
103
- var _a, _b, _c, _d, _e;
104
- const oauthWallet = (_b = (_a = user == null ? void 0 : user.accounts) == null ? void 0 : _a.find(
105
- (a) => a.type === "oauth" /* oauth */ && String(a.provider).toLowerCase() === "wallet"
106
- )) != null ? _b : null;
107
- if (oauthWallet == null ? void 0 : oauthWallet.providerAccountId) return oauthWallet.providerAccountId;
108
- const siweAccount = (_d = (_c = user == null ? void 0 : user.accounts) == null ? void 0 : _c.find((a) => a.type === "siwe" /* siwe */)) != null ? _d : null;
109
- return (_e = siweAccount == null ? void 0 : siweAccount.providerAccountId) != null ? _e : void 0;
110
- }
111
98
 
112
99
  // src/core/providers/contexts.ts
113
100
  var import_react = require("react");
@@ -276,6 +263,12 @@ var enUsLabels = {
276
263
  max: "Max",
277
264
  tokenLabel: "Receive token",
278
265
  networkLabel: "Receive network",
266
+ estimatedFees: "Est. fees",
267
+ networkReserve: "Network reserve",
268
+ networkReserveTooltipAria: "Network reserve details",
269
+ networkReserveTooltipLineOne: "This reserve helps cover network and bridge costs.",
270
+ networkReserveTooltipLineTwo: "Any unused amount stays in your balance.",
271
+ youReceive: "You'll receive",
279
272
  confirm: "Confirm withdrawal",
280
273
  successTitle: "Withdrawal submitted",
281
274
  successDescription: (tokenSymbol) => `Your ${tokenSymbol} withdrawal is being processed and will arrive shortly.`,
@@ -284,12 +277,16 @@ var enUsLabels = {
284
277
  // terminal status — otherwise a finished withdrawal would keep showing
285
278
  // "submitted / processing" forever and force the user to hard-refresh.
286
279
  successTitleCompleted: "Withdrawal complete",
287
- successDescriptionCompleted: (tokenSymbol) => `Your ${tokenSymbol} withdrawal has been delivered.`,
280
+ successDescriptionCompleted: (tokenSymbol) => `Your ${tokenSymbol} has been successfully sent to your wallet.`,
288
281
  successTitlePartial: "Withdrawal partially completed",
289
- successDescriptionPartial: (tokenSymbol) => `Some legs of your ${tokenSymbol} withdrawal completed; see details below.`,
282
+ successDescriptionPartial: () => "Part of your withdrawal was completed successfully, but the remaining funds failed to transfer and were returned to your balance.",
290
283
  successTitleFailed: "Withdrawal failed",
291
- successDescriptionFailed: (tokenSymbol) => `Your ${tokenSymbol} withdrawal could not be completed.`,
284
+ successDescriptionFailed: () => "We couldn't complete your withdrawal. Your funds were returned to your balance.",
285
+ retry: "Try Again",
286
+ close: "Close",
287
+ loadingDescription: "This may take a few minutes. You can safely close this window and check the status later in your activity.",
292
288
  summary: {
289
+ requestedWithdrawal: "Requested withdrawal",
293
290
  // The response is `pricingStatus: "unquoted"` — we don't know net
294
291
  // output until on-chain settlement. Calling this "Amount received"
295
292
  // would imply receipt before the lifecycle has confirmed. Keep it
@@ -307,6 +304,12 @@ var enUsLabels = {
307
304
  completed: "Withdrawal complete.",
308
305
  partial: "Withdrawal partially completed \u2014 see details below.",
309
306
  failed: "Withdrawal failed.",
307
+ loadingSteps: {
308
+ preparing: "Preparing funds",
309
+ bridging: "Bridging between networks",
310
+ sending: "Sending to your wallet",
311
+ confirming: "Waiting for network confirmation"
312
+ },
310
313
  steps: {
311
314
  bridge: (sourceChainName, destChainName) => `Bridging from ${sourceChainName} to ${destChainName}`,
312
315
  transfer: (destChainName) => `Transferring on ${destChainName}`
@@ -362,10 +365,37 @@ var enUsLabels = {
362
365
  externalWallet: "Deposit from external wallet",
363
366
  card: "Deposit with card"
364
367
  },
368
+ depositStatusTitles: {
369
+ connectedWallet: {
370
+ pending: "Processing deposit from connected wallet",
371
+ completed: "Successful deposit from connected wallet",
372
+ failed: "Failed deposit from connected wallet",
373
+ canceled: "Canceled deposit from connected wallet"
374
+ },
375
+ externalWallet: {
376
+ pending: "Processing deposit from external wallet",
377
+ completed: "Successful deposit from external wallet",
378
+ failed: "Failed deposit from external wallet",
379
+ canceled: "Canceled deposit from external wallet"
380
+ },
381
+ card: {
382
+ pending: "Processing deposit with card",
383
+ completed: "Successful deposit with card",
384
+ failed: "Failed deposit with card",
385
+ canceled: "Canceled deposit with card"
386
+ }
387
+ },
388
+ withdrawalStatusTitles: {
389
+ pending: "Processing withdrawal",
390
+ completed: "Successful withdrawal",
391
+ failed: "Failed withdrawal",
392
+ canceled: "Canceled withdrawal"
393
+ },
365
394
  // Activity-row title for any withdrawal regardless of lifecycle
366
- // state (pending / completed / failed) — render the asset rather
367
- // than implying success. The ActivityRow renders a separate status
368
- // chip when the row is failed.
395
+ // state — render the asset rather than implying success. The
396
+ // ActivityRow renders a separate status chip when the row is
397
+ // failed. Retained for partner overrides that still want a
398
+ // status-agnostic title.
369
399
  withdrawalTitle: (tokenSymbol) => `Withdraw ${tokenSymbol}`
370
400
  },
371
401
  positions: {
@@ -400,6 +430,15 @@ var enUsLabels = {
400
430
  eventList: {
401
431
  matchedTab: "Matched",
402
432
  allTab: "All",
433
+ sortByLabel: "Sort by",
434
+ sortBy24hVolume: "24h volume",
435
+ sortByTopArbitrage: "Top arbitrage",
436
+ sortByTotalVolume: "Total volume",
437
+ sortByEndingSoon: "Ending soon",
438
+ subcategoriesLabel: "Subcategories",
439
+ subcategoriesAll: "All",
440
+ subcategoriesOpenAria: "Open subcategories",
441
+ subcategoriesCloseAria: "Close subcategories",
403
442
  loading: (title) => `Loading ${title}`,
404
443
  tabsAria: (title) => `${title} tabs`,
405
444
  emptyAria: "No events found",
@@ -586,6 +625,19 @@ var enUsLabels = {
586
625
  noMarketSelected: "Select a market to place an order.",
587
626
  noOrderbooks: "No live orderbooks are available for this market right now.",
588
627
  quoteUnavailable: "Quote temporarily unavailable. Please try again.",
628
+ quoteBalanceMismatch: "Quote balance mismatch. Try a different amount.",
629
+ serviceTemporarilyUnavailable: "Service temporarily unavailable. Please try again in a moment.",
630
+ orderDeadlineExpiredBeforeSubmission: "Order deadline expired before submission. Please try again.",
631
+ sellNoOnchainPosition: "You don't currently hold any on-chain shares of this outcome. If you just sold or redeemed elsewhere, your position display will refresh shortly \u2014 try again after that.",
632
+ venueQuoteUnfillable: "The venue couldn't fill this order at the quoted price right now. Try a smaller size, a higher slippage tolerance, or wait a moment and re-quote.",
633
+ venueMinOrderSize: "Order size is below the venue minimum. Try a larger amount.",
634
+ sourceBalanceChanged: "Your balance changed since the quote. Refresh and try again, or pick a smaller amount.",
635
+ venueMarketResolved: "This market just resolved. Pick a different market or wait for the next round.",
636
+ dflowWalletUnverified: "Your Solana wallet needs to be verified with dFlow before you can trade Kalshi markets. Verify at https://dflow.net/proof, then try again.",
637
+ venueNoQuotePath: "No active quote path for this market right now. Try a different size, or wait a moment and re-quote.",
638
+ solanaBlockhashExpired: "Solana transaction expired before submission. Please re-quote and try again.",
639
+ venueRateLimited: "The venue is rate-limiting requests right now. Please wait a moment and try again.",
640
+ serviceBlockedOrder: "Something on our side blocked this order. Please contact support if it keeps happening \u2014 retrying with the same quote will hit the same issue.",
589
641
  selectedVenueUnavailable: "The venue you selected is no longer available on this route. Review the updated options and try again.",
590
642
  engineUnavailable: "The routing engine is temporarily unavailable. Please try again in a moment.",
591
643
  insufficientInputAmount: "Trade amount is too small to cover bridging and execution costs. Increase your spend or deposit funds on the destination chain.",
@@ -599,6 +651,7 @@ var enUsLabels = {
599
651
  deposit: "Deposit",
600
652
  kycRequired: "Verify to trade Kalshi",
601
653
  kycNotVerifiedTooltip: "You have not been verified yet",
654
+ kycVerify: "Verify Identity",
602
655
  kycVerifyModalTitle: "Verify Your Identity",
603
656
  kycVerifyModalDescription: "To start trading on Kalshi, you'll need to complete identity verification through dFlow. It only takes a few minutes and helps us stay compliant with regulations.",
604
657
  kycStartVerification: "Start Verification",
@@ -612,6 +665,7 @@ var enUsLabels = {
612
665
  splitOrderDescription: "We split your order for the best price:",
613
666
  viewAllRoutes: (count) => `View all (${count})`,
614
667
  venueUnavailableInRegion: "Unavailable in your region",
668
+ verified: "Verified",
615
669
  platformFee: "0% platform fees",
616
670
  estimatedFees: "Estimated fees",
617
671
  estimatedFeesTooltipAria: "Estimated fees breakdown",
@@ -623,6 +677,7 @@ var enUsLabels = {
623
677
  buyingOutcome: (label) => `Buying ${label}`,
624
678
  sellingOutcome: (label) => `Selling ${label}`,
625
679
  findingBestRoute: "Finding the best route...",
680
+ checkingBalance: "Checking balance",
626
681
  submittingOrderProgress: "Submitting order...",
627
682
  orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
628
683
  executingOnVenue: (venueLabel) => `Executing on ${venueLabel}...`,
@@ -802,6 +857,57 @@ var enUsLabels = {
802
857
  header: {
803
858
  bannerAria: "Site header",
804
859
  logoAria: "Home"
860
+ },
861
+ notifications: {
862
+ order: {
863
+ filledTitle: "Order filled",
864
+ filledMessage: ({ venueLabel, sideLabel, amountLabel, priceLabel }) => {
865
+ const action = sideLabel ? `${sideLabel} filled` : "Filled";
866
+ const amount = amountLabel ? ` ${amountLabel}` : "";
867
+ const price = priceLabel ? ` at ${priceLabel}` : "";
868
+ const venue = venueLabel ? ` on ${venueLabel}` : "";
869
+ return `${action}${amount}${price}${venue}`.trim();
870
+ },
871
+ partialFilledTitle: "Order partially filled",
872
+ partialFilledMessage: ({ venueLabel, sideLabel, amountLabel, priceLabel }) => {
873
+ const action = sideLabel ? `${sideLabel} partially filled` : "Partially filled";
874
+ const amount = amountLabel ? ` ${amountLabel}` : "";
875
+ const price = priceLabel ? ` at ${priceLabel}` : "";
876
+ const venue = venueLabel ? ` on ${venueLabel}` : "";
877
+ return `${action}${amount}${price}${venue}`.trim();
878
+ },
879
+ failedTitle: "Order failed",
880
+ failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your order could not be completed. Please try again."
881
+ },
882
+ deposit: {
883
+ completedTitle: "Deposit complete",
884
+ completedMessage: ({ amountLabel, tokenLabel }) => {
885
+ if (amountLabel && tokenLabel) return `${amountLabel} ${tokenLabel} added to your balance.`;
886
+ if (tokenLabel) return `Your ${tokenLabel} has been added to your balance.`;
887
+ return "Your funds have been added to your balance.";
888
+ },
889
+ failedTitle: "Deposit failed",
890
+ failedMessage: ({ amountLabel, tokenLabel }) => {
891
+ const what = amountLabel && tokenLabel ? `${amountLabel} ${tokenLabel}` : "deposit";
892
+ return `We couldn't complete your ${what}.`;
893
+ }
894
+ },
895
+ withdrawal: {
896
+ completedTitle: "Withdrawal complete",
897
+ completedMessage: ({ amountLabel, tokenLabel }) => {
898
+ if (amountLabel && tokenLabel) return `${amountLabel} ${tokenLabel} sent to your wallet.`;
899
+ if (tokenLabel) return `Your ${tokenLabel} has been sent to your wallet.`;
900
+ return "Your withdrawal has been sent to your wallet.";
901
+ },
902
+ partialTitle: "Withdrawal partially completed",
903
+ partialMessage: ({ amountLabel, tokenLabel }) => {
904
+ if (amountLabel && tokenLabel)
905
+ return `Part of your ${tokenLabel} was sent. The remainder was returned to your balance.`;
906
+ return "Part of your withdrawal was sent. The remainder was returned to your balance.";
907
+ },
908
+ failedTitle: "Withdrawal failed",
909
+ failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your funds have been returned to your balance."
910
+ }
805
911
  }
806
912
  };
807
913
  var defaultAggUiLabelsByLocale = {
@@ -861,6 +967,7 @@ var defaultAggUiSearchConfig = {
861
967
  var defaultAggUiConfig = {
862
968
  enableLogs: false,
863
969
  enableWebsocketsLogs: false,
970
+ enableDebug: false,
864
971
  general: {
865
972
  locale: DEFAULT_LOCALE,
866
973
  theme: "light",
@@ -871,7 +978,9 @@ var defaultAggUiConfig = {
871
978
  enableAnimations: true,
872
979
  enableLiveUpdates: true,
873
980
  showFeesBreakdown: false,
874
- enableGradients: false
981
+ enableGradients: false,
982
+ enableVenueEventDiscoveryFilters: false,
983
+ enableNotifications: true
875
984
  },
876
985
  market: {
877
986
  arbitrageThreshold: 0
@@ -935,6 +1044,33 @@ var invalidateBalanceQueries = (queryClient, options) => {
935
1044
  refetchType
936
1045
  });
937
1046
  };
1047
+ var invalidatePositionQueries = (queryClient, options) => {
1048
+ var _a;
1049
+ queryClient.invalidateQueries({
1050
+ queryKey: executionKeys.positionsPrefix(),
1051
+ refetchType: (_a = options == null ? void 0 : options.refetchType) != null ? _a : "active"
1052
+ });
1053
+ };
1054
+ var userActivityQueryKeys = {
1055
+ all: () => ["user-activity"]
1056
+ };
1057
+ var invalidateUserActivityQueries = (queryClient, options) => {
1058
+ var _a;
1059
+ const strategy = (_a = options == null ? void 0 : options.strategy) != null ? _a : "remove";
1060
+ if (strategy === "remove") {
1061
+ queryClient.removeQueries({ queryKey: userActivityQueryKeys.all() });
1062
+ return;
1063
+ }
1064
+ queryClient.invalidateQueries({
1065
+ queryKey: userActivityQueryKeys.all(),
1066
+ refetchType: "all"
1067
+ });
1068
+ };
1069
+ var invalidateUserMoneyState = (queryClient, options) => {
1070
+ invalidateBalanceQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
1071
+ invalidatePositionQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
1072
+ invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
1073
+ };
938
1074
 
939
1075
  // src/core/providers/hooks.ts
940
1076
  var import_react2 = require("react");
@@ -968,6 +1104,35 @@ var useAggBalanceState = useAggBalanceContext;
968
1104
  // src/deposit/constants.ts
969
1105
  var DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
970
1106
  var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
1107
+ var MULTI_CHAIN_SOLANA_WALLET_NAMES = /* @__PURE__ */ new Set(["Phantom"]);
1108
+
1109
+ // src/deposit/use-svm-address.ts
1110
+ var import_react3 = require("react");
1111
+ var import_wallet_adapter_react = require("@solana/wallet-adapter-react");
1112
+ function getPhantomProvider() {
1113
+ var _a, _b;
1114
+ if (typeof window === "undefined") return void 0;
1115
+ const w = window;
1116
+ return (_b = (_a = w.phantom) == null ? void 0 : _a.solana) != null ? _b : w.solana;
1117
+ }
1118
+ function useSvmAddress() {
1119
+ var _a;
1120
+ const { publicKey: adapterPublicKey } = (0, import_wallet_adapter_react.useWallet)();
1121
+ const [phantomAddress, setPhantomAddress] = (0, import_react3.useState)(void 0);
1122
+ (0, import_react3.useEffect)(() => {
1123
+ var _a2;
1124
+ const provider = getPhantomProvider();
1125
+ if (!provider) return;
1126
+ const existing = (_a2 = provider.publicKey) == null ? void 0 : _a2.toBase58();
1127
+ if (existing) {
1128
+ setPhantomAddress(existing);
1129
+ return;
1130
+ }
1131
+ provider.connect({ onlyIfTrusted: true }).then((res) => setPhantomAddress(res.publicKey.toString())).catch(() => {
1132
+ });
1133
+ }, []);
1134
+ return (_a = adapterPublicKey == null ? void 0 : adapterPublicKey.toBase58()) != null ? _a : phantomAddress;
1135
+ }
971
1136
 
972
1137
  // src/deposit/use-wallet-token-balance.ts
973
1138
  var ERC20_BALANCE_OF_ABI = [
@@ -979,11 +1144,46 @@ var ERC20_BALANCE_OF_ABI = [
979
1144
  outputs: [{ name: "", type: "uint256" }]
980
1145
  }
981
1146
  ];
982
- function getPhantomProvider() {
983
- var _a, _b;
984
- if (typeof window === "undefined") return void 0;
985
- const w = window;
986
- return (_b = (_a = w.phantom) == null ? void 0 : _a.solana) != null ? _b : w.solana;
1147
+ var SVM_BALANCE_RPC_TIMEOUT_MS = 2e3;
1148
+ var SVM_BALANCE_STALE_TIME_MS = 3e4;
1149
+ var SvmBalanceTimeoutError = class extends Error {
1150
+ constructor() {
1151
+ super("Solana balance request timed out");
1152
+ this.name = "SvmBalanceTimeoutError";
1153
+ }
1154
+ };
1155
+ function withTimeout(promise, timeoutMs) {
1156
+ return new Promise((resolve, reject) => {
1157
+ const timer = setTimeout(() => reject(new SvmBalanceTimeoutError()), timeoutMs);
1158
+ promise.then(
1159
+ (value) => {
1160
+ clearTimeout(timer);
1161
+ resolve(value);
1162
+ },
1163
+ (err) => {
1164
+ clearTimeout(timer);
1165
+ reject(err);
1166
+ }
1167
+ );
1168
+ });
1169
+ }
1170
+ function fetchSvmTokenBalance(rpcUrl, owner, mint) {
1171
+ return __async(this, null, function* () {
1172
+ var _a;
1173
+ const connection = new import_web3.Connection(rpcUrl);
1174
+ const accounts = yield withTimeout(
1175
+ connection.getTokenAccountsByOwner(owner, { mint }),
1176
+ SVM_BALANCE_RPC_TIMEOUT_MS
1177
+ );
1178
+ if (accounts.value.length === 0) return 0;
1179
+ const first = accounts.value[0];
1180
+ if (!first) return 0;
1181
+ const balance = yield withTimeout(
1182
+ connection.getTokenAccountBalance(first.pubkey),
1183
+ SVM_BALANCE_RPC_TIMEOUT_MS
1184
+ );
1185
+ return (_a = balance.value.uiAmount) != null ? _a : 0;
1186
+ });
987
1187
  }
988
1188
  function useWalletTokenBalance({
989
1189
  isOpen = true,
@@ -992,7 +1192,7 @@ function useWalletTokenBalance({
992
1192
  decimals,
993
1193
  svmAddress
994
1194
  }) {
995
- var _a, _b, _c;
1195
+ var _a;
996
1196
  const { solanaRpcUrl } = useAggUiConfig();
997
1197
  const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
998
1198
  const isSvm = chainId !== void 0 && SVM_CHAIN_IDS.has(chainId);
@@ -1006,45 +1206,27 @@ function useWalletTokenBalance({
1006
1206
  args: evmAddress ? [evmAddress] : void 0,
1007
1207
  query: { enabled: evmEnabled, staleTime: 0, refetchOnMount: true }
1008
1208
  });
1009
- const { publicKey: adapterPublicKey } = (0, import_wallet_adapter_react.useWallet)();
1010
- const [phantomAddress, setPhantomAddress] = (0, import_react3.useState)(void 0);
1011
- (0, import_react3.useEffect)(() => {
1012
- var _a2;
1013
- if (!isSvm) return;
1014
- const provider = getPhantomProvider();
1015
- if (!provider) return;
1016
- const existing = (_a2 = provider.publicKey) == null ? void 0 : _a2.toBase58();
1017
- if (existing) {
1018
- setPhantomAddress(existing);
1019
- return;
1020
- }
1021
- provider.connect({ onlyIfTrusted: true }).then((res) => setPhantomAddress(res.publicKey.toString())).catch(() => {
1022
- });
1023
- }, [isSvm]);
1024
- const resolvedSvmAddress = (_b = (_a = adapterPublicKey == null ? void 0 : adapterPublicKey.toBase58()) != null ? _a : phantomAddress) != null ? _b : svmAddress;
1025
- const connection = (0, import_react3.useMemo)(() => new import_web3.Connection(rpcEndpoint), [rpcEndpoint]);
1209
+ const detectedSvmAddress = useSvmAddress();
1210
+ const resolvedSvmAddress = detectedSvmAddress != null ? detectedSvmAddress : svmAddress;
1026
1211
  const svmEnabled = isOpen && isSvm && !!resolvedSvmAddress && !!tokenAddress;
1027
1212
  const svmQuery = (0, import_react_query.useQuery)({
1028
1213
  queryKey: ["svm-token-balance", resolvedSvmAddress != null ? resolvedSvmAddress : null, tokenAddress != null ? tokenAddress : null, isOpen],
1029
1214
  enabled: svmEnabled,
1030
- staleTime: 0,
1215
+ staleTime: SVM_BALANCE_STALE_TIME_MS,
1216
+ retry: false,
1217
+ refetchOnWindowFocus: "always",
1218
+ refetchOnReconnect: "always",
1031
1219
  queryFn: () => __async(null, null, function* () {
1032
- var _a2;
1033
1220
  if (!resolvedSvmAddress || !tokenAddress) return 0;
1034
1221
  const owner = new import_web3.PublicKey(resolvedSvmAddress);
1035
1222
  const mint = new import_web3.PublicKey(tokenAddress);
1036
- const accounts = yield connection.getTokenAccountsByOwner(owner, { mint });
1037
- if (accounts.value.length === 0) return 0;
1038
- const first = accounts.value[0];
1039
- if (!first) return 0;
1040
- const balance = yield connection.getTokenAccountBalance(first.pubkey);
1041
- return (_a2 = balance.value.uiAmount) != null ? _a2 : 0;
1223
+ return yield fetchSvmTokenBalance(rpcEndpoint, owner, mint);
1042
1224
  })
1043
1225
  });
1044
1226
  if (isSvm) {
1045
1227
  const awaitingSelection2 = isOpen && !!chainId && !tokenAddress;
1046
1228
  return {
1047
- balance: (_c = svmQuery.data) != null ? _c : 0,
1229
+ balance: (_a = svmQuery.data) != null ? _a : 0,
1048
1230
  isLoading: awaitingSelection2 || svmQuery.isLoading || svmQuery.isFetching
1049
1231
  };
1050
1232
  }
@@ -1372,7 +1554,7 @@ function useSyncBalances(options) {
1372
1554
  mutationFn: () => client.syncManagedBalances(),
1373
1555
  onSuccess: () => {
1374
1556
  var _a;
1375
- invalidateBalanceQueries(queryClient);
1557
+ invalidateUserMoneyState(queryClient);
1376
1558
  (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
1377
1559
  },
1378
1560
  onError: options == null ? void 0 : options.onError
@@ -1402,8 +1584,10 @@ function useRampSession() {
1402
1584
  }
1403
1585
 
1404
1586
  // src/deposit/use-deposit-flow.ts
1587
+ var DEFAULT_WALLET_CHAIN_ID = 1;
1588
+ var DEFAULT_WALLET_TOKEN_SYMBOL = "USDC";
1405
1589
  function useDepositFlow(options) {
1406
- var _a, _b;
1590
+ var _a, _b, _c;
1407
1591
  const { open, onOpenChange } = options;
1408
1592
  const { user } = useAggAuthState();
1409
1593
  const { walletActions } = useAggUiConfig();
@@ -1447,8 +1631,16 @@ function useDepositFlow(options) {
1447
1631
  }, []);
1448
1632
  const { chainId: connectedChainId, address: connectedAddress } = (0, import_wagmi4.useAccount)();
1449
1633
  const { switchChainAsync } = (0, import_wagmi4.useSwitchChain)();
1450
- const { publicKey: solanaPublicKey } = (0, import_wallet_adapter_react3.useWallet)();
1451
- const balanceChainId = walletModalChainId ? Number(walletModalChainId) : connectedChainId;
1634
+ const { wallet: solanaWallet } = (0, import_wallet_adapter_react3.useWallet)();
1635
+ const resolvedSvmAddress = useSvmAddress();
1636
+ const solanaAdapterName = (_b = solanaWallet == null ? void 0 : solanaWallet.adapter) == null ? void 0 : _b.name;
1637
+ const isMultiChainSolanaWallet = Boolean(
1638
+ solanaAdapterName && MULTI_CHAIN_SOLANA_WALLET_NAMES.has(solanaAdapterName)
1639
+ );
1640
+ const hasSolanaCapability = Boolean(resolvedSvmAddress || (solanaWallet == null ? void 0 : solanaWallet.adapter));
1641
+ const hasEvmCapability = Boolean(connectedAddress) || isMultiChainSolanaWallet;
1642
+ const defaultBalanceChainId = hasEvmCapability && (supportedChains == null ? void 0 : supportedChains.some((chain) => chain.chainId === DEFAULT_WALLET_CHAIN_ID)) ? DEFAULT_WALLET_CHAIN_ID : connectedChainId;
1643
+ const balanceChainId = walletModalChainId ? Number(walletModalChainId) : defaultBalanceChainId;
1452
1644
  const selectedChainTokens = (0, import_react7.useMemo)(() => {
1453
1645
  var _a2;
1454
1646
  if (!supportedChains || !balanceChainId) return [];
@@ -1456,23 +1648,17 @@ function useDepositFlow(options) {
1456
1648
  return (_a2 = chain == null ? void 0 : chain.tokens) != null ? _a2 : [];
1457
1649
  }, [supportedChains, balanceChainId]);
1458
1650
  const selectedTokenMeta = (0, import_react7.useMemo)(() => {
1459
- if (!walletModalTokenSymbol) return void 0;
1460
- const match = selectedChainTokens.find((t) => t.symbol === walletModalTokenSymbol);
1651
+ const preferredTokenSymbol = walletModalTokenSymbol != null ? walletModalTokenSymbol : DEFAULT_WALLET_TOKEN_SYMBOL;
1652
+ const match = selectedChainTokens.find((t) => t.symbol === preferredTokenSymbol);
1461
1653
  return match ? { address: match.address, decimals: match.decimals } : void 0;
1462
1654
  }, [selectedChainTokens, walletModalTokenSymbol]);
1463
- const authSvmAddress = (0, import_react7.useMemo)(() => {
1464
- var _a2;
1465
- const wallets = user == null ? void 0 : user.wallets;
1466
- return (_a2 = wallets == null ? void 0 : wallets.find((w) => w.chain === "solana" || w.chain === "svm")) == null ? void 0 : _a2.address;
1467
- }, [user]);
1468
1655
  const isSvmBalanceChain = balanceChainId !== void 0 && SVM_CHAIN_IDS.has(balanceChainId);
1469
1656
  const walletAddress = (0, import_react7.useMemo)(() => {
1470
- var _a2, _b2, _c;
1471
1657
  if (isSvmBalanceChain) {
1472
- return (_b2 = (_a2 = solanaPublicKey == null ? void 0 : solanaPublicKey.toBase58()) != null ? _a2 : authSvmAddress) != null ? _b2 : "";
1658
+ return resolvedSvmAddress != null ? resolvedSvmAddress : "";
1473
1659
  }
1474
- return (_c = connectedAddress != null ? connectedAddress : getWalletAddressFromUserProfile(user)) != null ? _c : "";
1475
- }, [authSvmAddress, connectedAddress, isSvmBalanceChain, solanaPublicKey, user]);
1660
+ return connectedAddress != null ? connectedAddress : "";
1661
+ }, [connectedAddress, isSvmBalanceChain, resolvedSvmAddress]);
1476
1662
  const walletLabel = (0, import_react7.useMemo)(() => {
1477
1663
  return walletAddress ? `${walletAddress.slice(0, 6)}...${walletAddress.slice(-4)}` : "\u2014";
1478
1664
  }, [walletAddress]);
@@ -1480,12 +1666,11 @@ function useDepositFlow(options) {
1480
1666
  isOpen: open,
1481
1667
  chainId: balanceChainId,
1482
1668
  tokenAddress: selectedTokenMeta == null ? void 0 : selectedTokenMeta.address,
1483
- decimals: selectedTokenMeta == null ? void 0 : selectedTokenMeta.decimals,
1484
- svmAddress: authSvmAddress
1669
+ decimals: selectedTokenMeta == null ? void 0 : selectedTokenMeta.decimals
1485
1670
  });
1486
1671
  const { status: observedWalletTransactionStatus, gasFee: walletTransactionGasFee } = useWalletTransactionStatus({
1487
1672
  chainId: walletTransaction == null ? void 0 : walletTransaction.chainId,
1488
- txId: (_b = walletTransaction == null ? void 0 : walletTransaction.txId) != null ? _b : null
1673
+ txId: (_c = walletTransaction == null ? void 0 : walletTransaction.txId) != null ? _c : null
1489
1674
  });
1490
1675
  const walletTransactionStatus = walletTransactionError ? "error" : walletTransaction ? observedWalletTransactionStatus != null ? observedWalletTransactionStatus : "submitted" : void 0;
1491
1676
  const syncedDepositTxIdRef = (0, import_react7.useRef)(null);
@@ -1513,9 +1698,15 @@ function useDepositFlow(options) {
1513
1698
  },
1514
1699
  [onOpenChange]
1515
1700
  );
1701
+ const handleCancelWalletDeposit = (0, import_react7.useCallback)(() => {
1702
+ setWalletTransaction(null);
1703
+ setWalletTransactionError(null);
1704
+ setWalletTransactionErrorTone("error");
1705
+ syncedDepositTxIdRef.current = null;
1706
+ }, []);
1516
1707
  const handleConfirmWalletDeposit = (0, import_react7.useCallback)(
1517
1708
  (params) => __async(null, null, function* () {
1518
- var _a2, _b2, _c;
1709
+ var _a2, _b2, _c2;
1519
1710
  const { address, amount, chainId, token } = params;
1520
1711
  const chain = (_a2 = supportedChains == null ? void 0 : supportedChains.find((c) => c.chainId === chainId)) != null ? _a2 : null;
1521
1712
  const tokenMeta = (_b2 = chain == null ? void 0 : chain.tokens.find((t) => t.symbol === token)) != null ? _b2 : null;
@@ -1531,7 +1722,7 @@ function useDepositFlow(options) {
1531
1722
  token: {
1532
1723
  symbol: token,
1533
1724
  address: tokenMeta == null ? void 0 : tokenMeta.address,
1534
- decimals: (_c = tokenMeta == null ? void 0 : tokenMeta.decimals) != null ? _c : 6
1725
+ decimals: (_c2 = tokenMeta == null ? void 0 : tokenMeta.decimals) != null ? _c2 : 6
1535
1726
  },
1536
1727
  to: address,
1537
1728
  amount
@@ -1599,11 +1790,12 @@ function useDepositFlow(options) {
1599
1790
  onWalletAmountChange: setDepositAmount,
1600
1791
  onWalletMax: (0, import_react7.useCallback)(() => setDepositAmount(String(walletBalance)), [walletBalance]),
1601
1792
  onConfirmWalletDeposit: handleConfirmWalletDeposit,
1793
+ onCancelWalletDeposit: handleCancelWalletDeposit,
1602
1794
  onWalletNetworkChange: setWalletModalChainId,
1603
1795
  onWalletTokenChange: setWalletModalTokenSymbol,
1604
1796
  initialWalletChainId: connectedChainId ? String(connectedChainId) : void 0,
1605
- connectedWalletKind: connectedChainId && !solanaPublicKey ? "evm" : solanaPublicKey && !connectedChainId ? "solana" : void 0,
1606
- sendCryptoConfig: { minDeposit: "$1", feeEstimate: "~$0.01", eta: "~30s" },
1797
+ connectedWalletKind: hasEvmCapability && !hasSolanaCapability ? "evm" : hasSolanaCapability && !hasEvmCapability ? "solana" : void 0,
1798
+ sendCryptoConfig: { minDeposit: "$1", eta: "~30s" },
1607
1799
  onDoneSendCrypto: (0, import_react7.useCallback)(
1608
1800
  () => handleDepositModalOpenChange(false),
1609
1801
  [handleDepositModalOpenChange]