@openfort/react 1.1.4 → 1.3.0

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.
Files changed (182) hide show
  1. package/build/assets/icons.js +1 -1
  2. package/build/assets/logos.d.ts +15 -0
  3. package/build/assets/logos.js +9 -0
  4. package/build/assets/logos.js.map +1 -1
  5. package/build/components/Common/CopyToClipboard/CopyIconButton.d.ts +3 -1
  6. package/build/components/Common/CopyToClipboard/CopyIconButton.js +4 -4
  7. package/build/components/Common/CustomQRCode/index.d.ts +1 -1
  8. package/build/components/Common/CustomQRCode/index.js +3 -3
  9. package/build/components/Common/CustomQRCode/styles.d.ts +1 -0
  10. package/build/components/Common/CustomQRCode/styles.js +4 -4
  11. package/build/components/Common/CustomQRCode/types.d.ts +2 -0
  12. package/build/components/Common/Modal/styles.js +4 -1
  13. package/build/components/Common/Modal/styles.js.map +1 -1
  14. package/build/components/Common/SolanaChain/index.d.ts +8 -0
  15. package/build/components/Common/SolanaChain/index.js +40 -0
  16. package/build/components/Common/SolanaChain/index.js.map +1 -0
  17. package/build/components/ConnectModal/index.js +16 -2
  18. package/build/components/ConnectModal/index.js.map +1 -1
  19. package/build/components/Openfort/OpenfortProvider.js +4 -1
  20. package/build/components/Openfort/OpenfortProvider.js.map +1 -1
  21. package/build/components/Openfort/types.d.ts +92 -0
  22. package/build/components/Openfort/types.js +23 -1
  23. package/build/components/Openfort/types.js.map +1 -1
  24. package/build/components/Pages/AssetInventory/SolanaAssetInventory.d.ts +6 -0
  25. package/build/components/Pages/AssetInventory/SolanaAssetInventory.js +42 -0
  26. package/build/components/Pages/AssetInventory/SolanaAssetInventory.js.map +1 -0
  27. package/build/components/Pages/Buy/coinbaseApi.d.ts +1 -1
  28. package/build/components/Pages/Buy/coinbaseApi.js +2 -13
  29. package/build/components/Pages/Buy/coinbaseApi.js.map +1 -1
  30. package/build/components/Pages/Buy/evmCurrencies.d.ts +11 -0
  31. package/build/components/Pages/Buy/evmCurrencies.js +27 -0
  32. package/build/components/Pages/Buy/evmCurrencies.js.map +1 -0
  33. package/build/components/Pages/Buy/index.js +11 -3
  34. package/build/components/Pages/Buy/index.js.map +1 -1
  35. package/build/components/Pages/Buy/onrampApi.d.ts +8 -1
  36. package/build/components/Pages/Buy/onrampApi.js +24 -14
  37. package/build/components/Pages/Buy/onrampApi.js.map +1 -1
  38. package/build/components/Pages/Buy/solanaCurrencies.d.ts +9 -0
  39. package/build/components/Pages/Buy/solanaCurrencies.js +25 -0
  40. package/build/components/Pages/Buy/solanaCurrencies.js.map +1 -0
  41. package/build/components/Pages/Buy/stripeApi.d.ts +1 -1
  42. package/build/components/Pages/Buy/stripeApi.js +2 -13
  43. package/build/components/Pages/Buy/stripeApi.js.map +1 -1
  44. package/build/components/Pages/BuyComplete/index.js +7 -1
  45. package/build/components/Pages/BuyComplete/index.js.map +1 -1
  46. package/build/components/Pages/BuyProcessing/index.js +9 -5
  47. package/build/components/Pages/BuyProcessing/index.js.map +1 -1
  48. package/build/components/Pages/BuySelectProvider/index.js +11 -6
  49. package/build/components/Pages/BuySelectProvider/index.js.map +1 -1
  50. package/build/components/Pages/Connected/EthereumConnected.js +8 -32
  51. package/build/components/Pages/Connected/EthereumConnected.js.map +1 -1
  52. package/build/components/Pages/Connected/SolanaConnected.js +11 -5
  53. package/build/components/Pages/Connected/SolanaConnected.js.map +1 -1
  54. package/build/components/Pages/Deposit/AddressPageLink.d.ts +7 -0
  55. package/build/components/Pages/Deposit/AddressPageLink.js +17 -0
  56. package/build/components/Pages/Deposit/AddressPageLink.js.map +1 -0
  57. package/build/components/Pages/Deposit/AssetChainLogo.d.ts +9 -0
  58. package/build/components/Pages/Deposit/AssetChainLogo.js +24 -0
  59. package/build/components/Pages/Deposit/AssetChainLogo.js.map +1 -0
  60. package/build/components/Pages/Deposit/DepositAddressBlock.d.ts +21 -0
  61. package/build/components/Pages/Deposit/DepositAddressBlock.js +28 -0
  62. package/build/components/Pages/Deposit/DepositAddressBlock.js.map +1 -0
  63. package/build/components/Pages/Deposit/DepositProgress.d.ts +15 -0
  64. package/build/components/Pages/Deposit/DepositProgress.js +111 -0
  65. package/build/components/Pages/Deposit/DepositProgress.js.map +1 -0
  66. package/build/components/Pages/Deposit/DepositStatus.d.ts +9 -0
  67. package/build/components/Pages/Deposit/DepositStatus.js +43 -0
  68. package/build/components/Pages/Deposit/DepositStatus.js.map +1 -0
  69. package/build/components/Pages/Deposit/DepositSuccess.d.ts +6 -0
  70. package/build/components/Pages/Deposit/DepositSuccess.js +25 -0
  71. package/build/components/Pages/Deposit/DepositSuccess.js.map +1 -0
  72. package/build/components/Pages/Deposit/Details.d.ts +12 -0
  73. package/build/components/Pages/Deposit/Details.js +40 -0
  74. package/build/components/Pages/Deposit/Details.js.map +1 -0
  75. package/build/components/Pages/Deposit/LogoSelect.d.ts +12 -0
  76. package/build/components/Pages/Deposit/LogoSelect.js +95 -0
  77. package/build/components/Pages/Deposit/LogoSelect.js.map +1 -0
  78. package/build/components/Pages/Deposit/OrDivider.d.ts +2 -0
  79. package/build/components/Pages/Deposit/OrDivider.js +10 -0
  80. package/build/components/Pages/Deposit/OrDivider.js.map +1 -0
  81. package/build/components/Pages/Deposit/RouteSelectors.d.ts +13 -0
  82. package/build/components/Pages/Deposit/RouteSelectors.js +19 -0
  83. package/build/components/Pages/Deposit/RouteSelectors.js.map +1 -0
  84. package/build/components/Pages/Deposit/cexChains.d.ts +9 -0
  85. package/build/components/Pages/Deposit/cexChains.js +23 -0
  86. package/build/components/Pages/Deposit/cexChains.js.map +1 -0
  87. package/build/components/Pages/Deposit/formStyles.d.ts +24 -0
  88. package/build/components/Pages/Deposit/formStyles.js +83 -0
  89. package/build/components/Pages/Deposit/formStyles.js.map +1 -0
  90. package/build/components/Pages/Deposit/index.d.ts +7 -0
  91. package/build/components/Pages/Deposit/index.js +114 -0
  92. package/build/components/Pages/Deposit/index.js.map +1 -0
  93. package/build/components/Pages/Deposit/paymentOptions.d.ts +49 -0
  94. package/build/components/Pages/Deposit/paymentOptions.js +63 -0
  95. package/build/components/Pages/Deposit/paymentOptions.js.map +1 -0
  96. package/build/components/Pages/Deposit/sources.d.ts +17 -0
  97. package/build/components/Pages/Deposit/sources.js +22 -0
  98. package/build/components/Pages/Deposit/sources.js.map +1 -0
  99. package/build/components/Pages/Deposit/styles.d.ts +25 -0
  100. package/build/components/Pages/Deposit/styles.js +167 -0
  101. package/build/components/Pages/Deposit/styles.js.map +1 -0
  102. package/build/components/Pages/Deposit/useDepositRoute.d.ts +34 -0
  103. package/build/components/Pages/Deposit/useDepositRoute.js +106 -0
  104. package/build/components/Pages/Deposit/useDepositRoute.js.map +1 -0
  105. package/build/components/Pages/Deposit/useFundingTarget.d.ts +11 -0
  106. package/build/components/Pages/Deposit/useFundingTarget.js +25 -0
  107. package/build/components/Pages/Deposit/useFundingTarget.js.map +1 -0
  108. package/build/components/Pages/DepositCex/index.d.ts +11 -0
  109. package/build/components/Pages/DepositCex/index.js +229 -0
  110. package/build/components/Pages/DepositCex/index.js.map +1 -0
  111. package/build/components/Pages/DepositCrypto/index.d.ts +8 -0
  112. package/build/components/Pages/DepositCrypto/index.js +31 -0
  113. package/build/components/Pages/DepositCrypto/index.js.map +1 -0
  114. package/build/components/Pages/DepositWallet/DepositWalletDesktop.d.ts +20 -0
  115. package/build/components/Pages/DepositWallet/DepositWalletDesktop.js +139 -0
  116. package/build/components/Pages/DepositWallet/DepositWalletDesktop.js.map +1 -0
  117. package/build/components/Pages/DepositWallet/index.d.ts +9 -0
  118. package/build/components/Pages/DepositWallet/index.js +107 -0
  119. package/build/components/Pages/DepositWallet/index.js.map +1 -0
  120. package/build/components/Pages/DepositWallet/walletDeeplinks.d.ts +50 -0
  121. package/build/components/Pages/DepositWallet/walletDeeplinks.js +109 -0
  122. package/build/components/Pages/DepositWallet/walletDeeplinks.js.map +1 -0
  123. package/build/components/Pages/ExportKey/index.js +10 -2
  124. package/build/components/Pages/ExportKey/index.js.map +1 -1
  125. package/build/components/Pages/NoAssetsAvailable/index.js +5 -21
  126. package/build/components/Pages/NoAssetsAvailable/index.js.map +1 -1
  127. package/build/components/Pages/SelectToken/SolanaSelectToken.d.ts +1 -0
  128. package/build/components/Pages/SelectToken/SolanaSelectToken.js +50 -0
  129. package/build/components/Pages/SelectToken/SolanaSelectToken.js.map +1 -0
  130. package/build/components/Pages/SelectToken/index.js +13 -2
  131. package/build/components/Pages/SelectToken/index.js.map +1 -1
  132. package/build/components/Pages/SelectToken/styles.js +1 -1
  133. package/build/components/Pages/Send/SolanaSend.d.ts +1 -0
  134. package/build/components/Pages/Send/SolanaSend.js +89 -0
  135. package/build/components/Pages/Send/SolanaSend.js.map +1 -0
  136. package/build/components/Pages/Send/index.d.ts +2 -1
  137. package/build/components/Pages/Send/index.js +0 -1
  138. package/build/components/Pages/Send/index.js.map +1 -1
  139. package/build/components/Pages/Send/utils.js +4 -1
  140. package/build/components/Pages/Send/utils.js.map +1 -1
  141. package/build/components/Pages/SendConfirmation/EstimatedFees.js +5 -3
  142. package/build/components/Pages/SendConfirmation/EstimatedFees.js.map +1 -1
  143. package/build/components/Pages/SendConfirmation/SolanaSendConfirmation.d.ts +1 -0
  144. package/build/components/Pages/SendConfirmation/SolanaSendConfirmation.js +121 -0
  145. package/build/components/Pages/SendConfirmation/SolanaSendConfirmation.js.map +1 -0
  146. package/build/components/Pages/SendConfirmation/index.js +4 -3
  147. package/build/components/Pages/SendConfirmation/index.js.map +1 -1
  148. package/build/constants/logos.js +1 -0
  149. package/build/constants/logos.js.map +1 -1
  150. package/build/ethereum/hooks/useEthereumWalletAssets.js +212 -95
  151. package/build/ethereum/hooks/useEthereumWalletAssets.js.map +1 -1
  152. package/build/hooks/openfort/fundingClient.d.ts +34 -0
  153. package/build/hooks/openfort/fundingClient.js +60 -0
  154. package/build/hooks/openfort/fundingClient.js.map +1 -0
  155. package/build/hooks/openfort/useFunding.d.ts +159 -0
  156. package/build/hooks/openfort/useFunding.js +204 -0
  157. package/build/hooks/openfort/useFunding.js.map +1 -0
  158. package/build/hooks/openfort/useFundingChains.d.ts +49 -0
  159. package/build/hooks/openfort/useFundingChains.js +100 -0
  160. package/build/hooks/openfort/useFundingChains.js.map +1 -0
  161. package/build/hooks/useBalance.js +6 -1
  162. package/build/hooks/useBalance.js.map +1 -1
  163. package/build/index.d.ts +4 -1
  164. package/build/index.js +2 -1
  165. package/build/index.js.map +1 -1
  166. package/build/shared/hooks/useAsyncData.d.ts +11 -0
  167. package/build/shared/hooks/useAsyncData.js +73 -13
  168. package/build/shared/hooks/useAsyncData.js.map +1 -1
  169. package/build/solana/hooks/useSolanaWalletAssets.d.ts +24 -0
  170. package/build/solana/hooks/useSolanaWalletAssets.js +86 -0
  171. package/build/solana/hooks/useSolanaWalletAssets.js.map +1 -0
  172. package/build/solana/transfer.d.ts +61 -0
  173. package/build/solana/transfer.js +219 -0
  174. package/build/solana/transfer.js.map +1 -0
  175. package/build/solana/types.d.ts +8 -0
  176. package/build/utils/index.d.ts +2 -1
  177. package/build/utils/index.js +1 -1
  178. package/build/version.d.ts +1 -1
  179. package/build/version.js +1 -1
  180. package/build/wagmi/defaultConnectors.js +5 -1
  181. package/build/wagmi/defaultConnectors.js.map +1 -1
  182. package/package.json +13 -1
@@ -5,6 +5,7 @@ import { useAsyncData } from '../../../shared/hooks/useAsyncData.js';
5
5
  import { logger } from '../../../utils/logger.js';
6
6
  import { getDefaultEthereumRpcUrl } from '../../../utils/rpc.js';
7
7
  import Tooltip from '../../Common/Tooltip/index.js';
8
+ import { useOpenfort } from '../../Openfort/useOpenfort.js';
8
9
  import { formatBalance } from '../Send/utils.js';
9
10
  import { InfoIconWrapper } from './styles.js';
10
11
 
@@ -17,16 +18,17 @@ const usdFormatter = new Intl.NumberFormat('en-US', {
17
18
  });
18
19
  const EstimatedFees = ({ account, to, value, data, chainId, nativeSymbol, enabled = true, hideInfoIcon = false, }) => {
19
20
  var _a, _b, _c;
21
+ const { walletConfig } = useOpenfort();
20
22
  const { data: assets } = useEthereumWalletAssets();
21
23
  const pricePerToken = (_c = (_b = (_a = assets === null || assets === void 0 ? void 0 : assets.find((a) => a.type === 'native')) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fiat) === null || _c === void 0 ? void 0 : _c.value;
22
24
  const gas = useAsyncData({
23
25
  queryKey: ['gas-estimate', account, to, value, data, chainId],
24
26
  queryFn: async () => {
25
- var _a;
27
+ var _a, _b, _c, _d;
26
28
  if (!account || !to || !chainId)
27
29
  return null;
28
30
  try {
29
- const rpcUrl = getDefaultEthereumRpcUrl(chainId);
31
+ const rpcUrl = (_c = (_b = (_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.rpcUrls) === null || _b === void 0 ? void 0 : _b[chainId]) !== null && _c !== void 0 ? _c : getDefaultEthereumRpcUrl(chainId);
30
32
  const publicClient = createPublicClient({ transport: http(rpcUrl) });
31
33
  const [gasEstimate, feesPerGas] = await Promise.all([
32
34
  publicClient.estimateGas({
@@ -37,7 +39,7 @@ const EstimatedFees = ({ account, to, value, data, chainId, nativeSymbol, enable
37
39
  }),
38
40
  publicClient.estimateFeesPerGas(),
39
41
  ]);
40
- const estimatedCost = gasEstimate * ((_a = feesPerGas.maxFeePerGas) !== null && _a !== void 0 ? _a : BigInt(0));
42
+ const estimatedCost = gasEstimate * ((_d = feesPerGas.maxFeePerGas) !== null && _d !== void 0 ? _d : BigInt(0));
41
43
  return { estimatedCost, gasLimit: gasEstimate };
42
44
  }
43
45
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"EstimatedFees.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"EstimatedFees.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export declare const SolanaSendConfirmation: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,121 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { ChainTypeEnum } from '@openfort/openfort-js';
3
+ import { useState, useEffect } from 'react';
4
+ import { parseUnits } from 'viem';
5
+ import { getExplorerUrl } from '../../../shared/utils/explorer.js';
6
+ import { useSolanaEmbeddedWallet } from '../../../solana/hooks/useSolanaEmbeddedWallet.js';
7
+ import { sendSplTokenGasless, sendSplToken, sendSolGasless, sendSol } from '../../../solana/transfer.js';
8
+ import 'detect-browser';
9
+ import { truncateSolanaAddress } from '../../../utils/format.js';
10
+ import Button from '../../Common/Button/index.js';
11
+ import { CopyText } from '../../Common/CopyToClipboard/CopyText.js';
12
+ import Loader from '../../Common/Loading/index.js';
13
+ import { ModalHeading, ModalBody } from '../../Common/Modal/styles.js';
14
+ import { routes } from '../../Openfort/types.js';
15
+ import { useOpenfort } from '../../Openfort/useOpenfort.js';
16
+ import { PageContent } from '../../PageContent/index.js';
17
+ import { ButtonRow, SummaryList, SummaryItem, SummaryLabel, AmountValue, AddressValue, FeesValue, ErrorContainer, ErrorTitle, ErrorMessage } from './styles.js';
18
+
19
+ const SOL_DECIMALS = 9;
20
+ const SolanaSendConfirmation = () => {
21
+ var _a, _b;
22
+ const { sendForm, setRoute, publishableKey, triggerResize, walletConfig } = useOpenfort();
23
+ const wallet = useSolanaEmbeddedWallet();
24
+ const address = wallet.status === 'connected' ? wallet.address : undefined;
25
+ const provider = wallet.status === 'connected' ? wallet.provider : undefined;
26
+ const cluster = (_a = wallet.cluster) !== null && _a !== void 0 ? _a : 'devnet';
27
+ const rpcUrl = wallet.rpcUrl;
28
+ const recipient = sendForm.recipient;
29
+ const amount = sendForm.amount;
30
+ const asset = sendForm.asset;
31
+ const symbol = asset.type === 'spl' ? asset.metadata.symbol : 'SOL';
32
+ const decimals = asset.type === 'spl' ? asset.metadata.decimals : SOL_DECIMALS;
33
+ // Fees are sponsored from config (the SVM counterpart of ethereumFeeSponsorshipId).
34
+ const isSponsored = Boolean((_b = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.solana) === null || _b === void 0 ? void 0 : _b.sponsorFees);
35
+ const [isLoading, setIsLoading] = useState(false);
36
+ const [signature, setSignature] = useState(null);
37
+ const [error, setError] = useState(null);
38
+ // Re-measure the modal when the result/error appears.
39
+ useEffect(() => {
40
+ const id = setTimeout(triggerResize, 10);
41
+ return () => clearTimeout(id);
42
+ }, [signature, error, isLoading, triggerResize]);
43
+ const handleConfirm = async () => {
44
+ if (!address || !provider || isLoading)
45
+ return;
46
+ // The Send screen validates these before navigating here; re-guard in case
47
+ // this page is reached directly with an unvalidated form.
48
+ if (!recipient.trim()) {
49
+ setError('Enter a recipient address.');
50
+ return;
51
+ }
52
+ const amountNum = Number(amount);
53
+ if (!Number.isFinite(amountNum) || amountNum <= 0) {
54
+ setError('Enter a valid amount.');
55
+ return;
56
+ }
57
+ if (!isSponsored && !rpcUrl) {
58
+ setError('No Solana RPC is configured for this network.');
59
+ return;
60
+ }
61
+ setIsLoading(true);
62
+ setError(null);
63
+ try {
64
+ let sig;
65
+ if (asset.type === 'spl') {
66
+ const baseUnits = parseUnits(amount, decimals);
67
+ sig = isSponsored
68
+ ? await sendSplTokenGasless({
69
+ from: address,
70
+ to: recipient,
71
+ mint: asset.address,
72
+ amount: baseUnits,
73
+ provider,
74
+ cluster,
75
+ publishableKey,
76
+ })
77
+ : await sendSplToken({
78
+ from: address,
79
+ to: recipient,
80
+ mint: asset.address,
81
+ amount: baseUnits,
82
+ decimals,
83
+ provider,
84
+ rpcUrl: rpcUrl !== null && rpcUrl !== void 0 ? rpcUrl : '',
85
+ });
86
+ }
87
+ else {
88
+ sig = isSponsored
89
+ ? await sendSolGasless({
90
+ from: address,
91
+ to: recipient,
92
+ amountSol: amountNum,
93
+ provider,
94
+ cluster,
95
+ publishableKey,
96
+ })
97
+ : await sendSol({ from: address, to: recipient, amountSol: amountNum, provider, rpcUrl: rpcUrl !== null && rpcUrl !== void 0 ? rpcUrl : '' });
98
+ }
99
+ setSignature(sig);
100
+ }
101
+ catch (err) {
102
+ setError(err instanceof Error ? err.message : 'Transaction failed');
103
+ }
104
+ finally {
105
+ setIsLoading(false);
106
+ }
107
+ };
108
+ const handleFinish = () => setRoute(routes.SOL_CONNECTED);
109
+ const handleViewExplorer = () => {
110
+ if (!signature)
111
+ return;
112
+ window.open(getExplorerUrl(ChainTypeEnum.SVM, { txHash: signature, cluster }), '_blank', 'noopener,noreferrer');
113
+ };
114
+ if (signature) {
115
+ return (jsxs(PageContent, { children: [jsx(Loader, { isSuccess: true, header: "Transfer sent", description: `${amount} ${symbol} sent successfully` }), jsxs(ButtonRow, { children: [jsx(Button, { variant: "primary", onClick: handleViewExplorer, children: "View on Explorer" }), jsx(Button, { variant: "secondary", onClick: handleFinish, children: "Back to profile" })] })] }));
116
+ }
117
+ return (jsxs(PageContent, { onBack: routes.SOL_SEND, children: [jsx(ModalHeading, { children: "Confirm transfer" }), jsx(ModalBody, { children: "Review the transaction details before sending." }), jsxs(SummaryList, { children: [jsxs(SummaryItem, { children: [jsx(SummaryLabel, { children: "Sending" }), jsxs(AmountValue, { children: [amount || '0', " ", symbol] })] }), jsxs(SummaryItem, { children: [jsx(SummaryLabel, { children: "From" }), jsx(AddressValue, { children: address ? (jsx(CopyText, { size: "1rem", value: address, children: truncateSolanaAddress(address) })) : ('--') })] }), jsxs(SummaryItem, { children: [jsx(SummaryLabel, { children: "To" }), jsx(AddressValue, { children: recipient ? (jsx(CopyText, { size: "1rem", value: recipient, children: truncateSolanaAddress(recipient) })) : ('--') })] }), isSponsored && (jsxs(SummaryItem, { children: [jsx(SummaryLabel, { children: "Network fee" }), jsx(FeesValue, { "$completed": true, children: "Sponsored" })] }))] }), error && (jsxs(ErrorContainer, { children: [jsx(ErrorTitle, { children: "Transaction failed" }), jsx(ErrorMessage, { children: error })] })), jsxs(ButtonRow, { children: [jsx(Button, { variant: "primary", onClick: handleConfirm, disabled: !address || isLoading, waiting: isLoading, children: isLoading ? 'Confirming...' : 'Confirm' }), jsx(Button, { variant: "secondary", onClick: () => setRoute(routes.SOL_SEND), disabled: isLoading, children: "Cancel" })] })] }));
118
+ };
119
+
120
+ export { SolanaSendConfirmation };
121
+ //# sourceMappingURL=SolanaSendConfirmation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolanaSendConfirmation.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -21,7 +21,7 @@ import { ModalHeading, ModalBody } from '../../Common/Modal/styles.js';
21
21
  import { routes } from '../../Openfort/types.js';
22
22
  import { useOpenfort } from '../../Openfort/useOpenfort.js';
23
23
  import { PageContent } from '../../PageContent/index.js';
24
- import { sanitizeForParsing, isSameToken, getAssetSymbol, getAssetDecimals } from '../Send/utils.js';
24
+ import { sanitizeForParsing, isSameToken, getAssetDecimals, getAssetSymbol } from '../Send/utils.js';
25
25
  import { EstimatedFees } from './EstimatedFees.js';
26
26
  import { ButtonRow, SummaryList, SummaryItem, SummaryLabel, AmountValue, AddressValue, FeesValue, CheckIconWrapper, StatusMessage, ErrorContainer, ErrorTitle, ErrorMessage, ErrorAction } from './styles.js';
27
27
 
@@ -69,10 +69,11 @@ const SendConfirmation = () => {
69
69
  const erc20Balance = useAsyncData({
70
70
  queryKey: ['erc20-balance', address, token.type === 'erc20' ? token.address : null, chainId],
71
71
  queryFn: async () => {
72
+ var _a, _b, _c, _d;
72
73
  if (!isErc20 || !address || !chainId)
73
74
  return { value: BigInt(0), decimals: 18, symbol: 'ERC20' };
74
75
  try {
75
- const rpcUrl = getDefaultEthereumRpcUrl(chainId);
76
+ const rpcUrl = (_c = (_b = (_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.rpcUrls) === null || _b === void 0 ? void 0 : _b[chainId]) !== null && _c !== void 0 ? _c : getDefaultEthereumRpcUrl(chainId);
76
77
  const publicClient = createPublicClient({ transport: http(rpcUrl) });
77
78
  const balance = await publicClient.readContract({
78
79
  address: token.address,
@@ -80,7 +81,7 @@ const SendConfirmation = () => {
80
81
  functionName: 'balanceOf',
81
82
  args: [address],
82
83
  });
83
- return { value: balance, decimals: 18, symbol: getAssetSymbol(token) };
84
+ return { value: balance, decimals: (_d = getAssetDecimals(token)) !== null && _d !== void 0 ? _d : 18, symbol: getAssetSymbol(token) };
84
85
  }
85
86
  catch (error) {
86
87
  logger.error('Failed to fetch ERC20 balance:', error);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -7,6 +7,7 @@ const TOKEN_LOGO = {
7
7
  TBNB: `${TW}/smartchain/info/logo.png`,
8
8
  MATIC: `${TW}/polygon/info/logo.png`,
9
9
  POL: `${TW}/polygon/info/logo.png`,
10
+ SOL: `${TW}/solana/info/logo.png`,
10
11
  AVAX: `${TW}/avalanchec/info/logo.png`,
11
12
  FTM: `${TW}/fantom/info/logo.png`,
12
13
  CELO: `${TW}/celo/info/logo.png`,
@@ -1 +1 @@
1
- {"version":3,"file":"logos.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"logos.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,11 +1,12 @@
1
1
  import { useCallback, useMemo } from 'react';
2
- import { numberToHex, custom, createWalletClient, formatUnits } from 'viem';
2
+ import { numberToHex, custom, createWalletClient, formatUnits, createPublicClient, http, erc20Abi } from 'viem';
3
3
  import { erc7811Actions } from 'viem/experimental';
4
4
  import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
5
5
  import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
6
6
  import { useUser } from '../../hooks/openfort/useUser.js';
7
7
  import { openfortKeys } from '../../query/queryKeys.js';
8
8
  import { useAsyncData } from '../../shared/hooks/useAsyncData.js';
9
+ import { getDefaultEthereumRpcUrl } from '../../utils/rpc.js';
9
10
  import { useEthereumEmbeddedWallet } from './useEthereumEmbeddedWallet.js';
10
11
 
11
12
  function getUsdValue(asset) {
@@ -17,6 +18,84 @@ function getUsdValue(asset) {
17
18
  const amount = Number.parseFloat(formatUnits(asset.balance, decimals));
18
19
  return Number.isFinite(amount) ? amount * fiat.value : 0;
19
20
  }
21
+ /** Stablecoins approximated at $1 in fallback mode (no price feed available). */
22
+ const STABLECOIN_SYMBOLS = new Set(['USDC', 'USDT', 'DAI']);
23
+ /**
24
+ * Canonical Multicall3 address — same on every major chain. Passed explicitly so
25
+ * multicall works even when the SDK's chain config doesn't declare a multicall3.
26
+ */
27
+ const MULTICALL3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
28
+ /**
29
+ * Reads native + configured ERC-20 balances directly from the chain RPC.
30
+ *
31
+ * Fallback for when Openfort's ERC-7811 asset proxy is unavailable: the widget
32
+ * still shows on-chain balances (no fiat valuation — that comes from the proxy,
33
+ * except stablecoins which are approximated at $1). Tokens that don't exist on
34
+ * the chain are skipped.
35
+ */
36
+ async function readEvmAssetsViaRpc(args) {
37
+ const { address, chain, rpcUrl, tokens } = args;
38
+ const client = createPublicClient({ chain, transport: http(rpcUrl) });
39
+ const out = [];
40
+ // Native balance — one call. Skipped silently if it fails (best-effort).
41
+ try {
42
+ const native = await client.getBalance({ address });
43
+ out.push({
44
+ type: 'native',
45
+ address: 'native',
46
+ balance: native,
47
+ metadata: {
48
+ symbol: chain.nativeCurrency.symbol,
49
+ decimals: chain.nativeCurrency.decimals,
50
+ fiat: { value: 0, currency: 'USD' },
51
+ },
52
+ });
53
+ }
54
+ catch {
55
+ // native read failed for this chain — skip it
56
+ }
57
+ if (tokens.length === 0)
58
+ return out;
59
+ // Batch every token's balanceOf/decimals/symbol/name into ONE multicall request
60
+ // (via Multicall3) instead of 4 calls per token — keeps us well under public-RPC
61
+ // rate limits (429s) that previously broke the fallback.
62
+ const contracts = tokens.flatMap((token) => [
63
+ { address: token, abi: erc20Abi, functionName: 'balanceOf', args: [address] },
64
+ { address: token, abi: erc20Abi, functionName: 'decimals' },
65
+ { address: token, abi: erc20Abi, functionName: 'symbol' },
66
+ { address: token, abi: erc20Abi, functionName: 'name' },
67
+ ]);
68
+ try {
69
+ const results = await client.multicall({ contracts, allowFailure: true, multicallAddress: MULTICALL3_ADDRESS });
70
+ tokens.forEach((token, i) => {
71
+ const balance = results[i * 4];
72
+ const decimals = results[i * 4 + 1];
73
+ const symbol = results[i * 4 + 2];
74
+ const name = results[i * 4 + 3];
75
+ if ((balance === null || balance === void 0 ? void 0 : balance.status) !== 'success' || (decimals === null || decimals === void 0 ? void 0 : decimals.status) !== 'success' || (symbol === null || symbol === void 0 ? void 0 : symbol.status) !== 'success')
76
+ return;
77
+ const sym = symbol.result;
78
+ out.push({
79
+ type: 'erc20',
80
+ address: token,
81
+ balance: balance.result,
82
+ metadata: {
83
+ name: ((name === null || name === void 0 ? void 0 : name.status) === 'success' ? name.result : sym),
84
+ symbol: sym,
85
+ decimals: decimals.result,
86
+ // No price feed in fallback mode; approximate stablecoins at $1 so the
87
+ // USD total isn't blank. Other tokens show their amount without a value.
88
+ fiat: STABLECOIN_SYMBOLS.has(sym.toUpperCase()) ? { value: 1, currency: 'USD' } : undefined,
89
+ },
90
+ });
91
+ });
92
+ }
93
+ catch {
94
+ // Multicall request itself failed (RPC throttled, or no Multicall3 on the chain).
95
+ // Return whatever we have (native) rather than throwing away the whole fetch.
96
+ }
97
+ return out;
98
+ }
20
99
  /**
21
100
  * Returns wallet assets (tokens, NFTs) for the connected Ethereum address.
22
101
  * Uses ERC-7811 via Openfort's authenticated RPC proxy.
@@ -116,7 +195,7 @@ const useEthereumWalletAssets = ({ assets: hookCustomAssets, multiChain = false,
116
195
  ? ['wallet-assets', 'multi', address, customAssetsMultiChain]
117
196
  : [...openfortKeys.walletAssets(chainId, customAssetsToFetch, address)],
118
197
  queryFn: async () => {
119
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
198
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
120
199
  if (multiChain) {
121
200
  if (!address) {
122
201
  throw new OpenfortError('No wallet address available', OpenfortReactErrorType.UNEXPECTED_ERROR);
@@ -146,7 +225,19 @@ const useEthereumWalletAssets = ({ assets: hookCustomAssets, multiChain = false,
146
225
  : null;
147
226
  const responses = await Promise.all([defaultRequest, customRequest].filter(Boolean));
148
227
  const [defaultData, customData] = await Promise.all(responses.map((r) => r.json()));
149
- const result = { ...((_a = defaultData.result) !== null && _a !== void 0 ? _a : {}) };
228
+ if (defaultData === null || defaultData === void 0 ? void 0 : defaultData.error) {
229
+ // ERC-7811 asset proxy failed — fall back to per-chain RPC reads.
230
+ const out = [];
231
+ for (const c of chains) {
232
+ const tokens = ((_c = (_b = (_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.assets) === null || _b === void 0 ? void 0 : _b[c.id]) !== null && _c !== void 0 ? _c : []);
233
+ const rpcUrl = (_f = (_e = (_d = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _d === void 0 ? void 0 : _d.rpcUrls) === null || _e === void 0 ? void 0 : _e[c.id]) !== null && _f !== void 0 ? _f : getDefaultEthereumRpcUrl(c.id);
234
+ const rpcAssets = await readEvmAssetsViaRpc({ address: address, chain: c, rpcUrl, tokens });
235
+ for (const a of rpcAssets)
236
+ out.push({ ...a, chainId: c.id });
237
+ }
238
+ return out;
239
+ }
240
+ const result = { ...((_g = defaultData.result) !== null && _g !== void 0 ? _g : {}) };
150
241
  if ((customData === null || customData === void 0 ? void 0 : customData.result) && typeof customData.result === 'object') {
151
242
  for (const [chainKey, assets] of Object.entries(customData.result)) {
152
243
  if (!Array.isArray(assets))
@@ -157,7 +248,7 @@ const useEthereumWalletAssets = ({ assets: hookCustomAssets, multiChain = false,
157
248
  else {
158
249
  const existing = new Map(result[chainKey].map((a) => { var _a; return [(_a = a.address) !== null && _a !== void 0 ? _a : '', a]; }));
159
250
  for (const asset of assets) {
160
- existing.set((_b = asset.address) !== null && _b !== void 0 ? _b : '', asset);
251
+ existing.set((_h = asset.address) !== null && _h !== void 0 ? _h : '', asset);
161
252
  }
162
253
  result[chainKey] = Array.from(existing.values());
163
254
  }
@@ -172,28 +263,28 @@ const useEthereumWalletAssets = ({ assets: hookCustomAssets, multiChain = false,
172
263
  if (a.type === 'erc20') {
173
264
  const asset = {
174
265
  type: 'erc20',
175
- address: ((_c = a.address) !== null && _c !== void 0 ? _c : '0x0'),
176
- balance: BigInt((_d = a.balance) !== null && _d !== void 0 ? _d : 0),
266
+ address: ((_j = a.address) !== null && _j !== void 0 ? _j : '0x0'),
267
+ balance: BigInt((_k = a.balance) !== null && _k !== void 0 ? _k : 0),
177
268
  metadata: {
178
- name: ((_e = a.metadata) === null || _e === void 0 ? void 0 : _e.name) || 'Unknown Token',
179
- symbol: ((_f = a.metadata) === null || _f === void 0 ? void 0 : _f.symbol) || 'UNKNOWN',
180
- decimals: (_g = a.metadata) === null || _g === void 0 ? void 0 : _g.decimals,
181
- fiat: (_h = a.metadata) === null || _h === void 0 ? void 0 : _h.fiat,
269
+ name: ((_l = a.metadata) === null || _l === void 0 ? void 0 : _l.name) || 'Unknown Token',
270
+ symbol: ((_m = a.metadata) === null || _m === void 0 ? void 0 : _m.symbol) || 'UNKNOWN',
271
+ decimals: (_o = a.metadata) === null || _o === void 0 ? void 0 : _o.decimals,
272
+ fiat: (_p = a.metadata) === null || _p === void 0 ? void 0 : _p.fiat,
182
273
  },
183
274
  raw: a,
184
275
  };
185
276
  allAssets.push({ ...asset, chainId: cid });
186
277
  }
187
278
  else if (a.type === 'native') {
188
- const meta = ((_j = a.metadata) !== null && _j !== void 0 ? _j : {});
279
+ const meta = ((_q = a.metadata) !== null && _q !== void 0 ? _q : {});
189
280
  const asset = {
190
281
  type: 'native',
191
282
  address: 'native',
192
- balance: BigInt((_k = a.balance) !== null && _k !== void 0 ? _k : 0),
283
+ balance: BigInt((_r = a.balance) !== null && _r !== void 0 ? _r : 0),
193
284
  metadata: {
194
285
  symbol: meta.symbol || 'ETH',
195
286
  decimals: meta.decimals,
196
- fiat: (_l = meta.fiat) !== null && _l !== void 0 ? _l : { value: 0, currency: 'USD' },
287
+ fiat: (_s = meta.fiat) !== null && _s !== void 0 ? _s : { value: 0, currency: 'USD' },
197
288
  },
198
289
  raw: a,
199
290
  };
@@ -210,92 +301,118 @@ const useEthereumWalletAssets = ({ assets: hookCustomAssets, multiChain = false,
210
301
  error: new Error('Address, chainId, or chain not available'),
211
302
  });
212
303
  }
213
- const customClient = createWalletClient({
214
- account: address,
215
- chain,
216
- transport: customTransport(),
217
- });
218
- const extendedClient = customClient.extend(erc7811Actions());
219
- const defaultAssetsPromise = extendedClient.getAssets({
220
- chainIds: [chainId],
221
- });
222
- const hexChainId = numberToHex(chainId);
223
- const customAssetsPromise = customAssetsToFetch.length > 0
224
- ? extendedClient.getAssets({
304
+ try {
305
+ const customClient = createWalletClient({
306
+ account: address,
307
+ chain,
308
+ transport: customTransport(),
309
+ });
310
+ const extendedClient = customClient.extend(erc7811Actions());
311
+ const defaultAssetsPromise = extendedClient.getAssets({
225
312
  chainIds: [chainId],
226
- assets: {
227
- [hexChainId]: customAssetsToFetch.map((a) => ({
228
- address: a,
313
+ });
314
+ const hexChainId = numberToHex(chainId);
315
+ const customAssetsPromise = customAssetsToFetch.length > 0
316
+ ? extendedClient.getAssets({
317
+ chainIds: [chainId],
318
+ assets: {
319
+ [hexChainId]: customAssetsToFetch.map((a) => ({
320
+ address: a,
321
+ type: 'erc20',
322
+ })),
323
+ },
324
+ })
325
+ : Promise.resolve({ [hexChainId]: [] });
326
+ const [defaultAssetsRaw, customAssets] = await Promise.all([defaultAssetsPromise, customAssetsPromise]);
327
+ // ERC-7811 response keys may be hex (e.g. "0x14a34") or numeric depending on the RPC
328
+ const rawByChain = defaultAssetsRaw;
329
+ const customByChain = customAssets;
330
+ const rawChainAssets = (_u = (_t = rawByChain[hexChainId]) !== null && _t !== void 0 ? _t : rawByChain[String(chainId)]) !== null && _u !== void 0 ? _u : [];
331
+ const customChainAssets = (_w = (_v = customByChain[hexChainId]) !== null && _v !== void 0 ? _v : customByChain[String(chainId)]) !== null && _w !== void 0 ? _w : [];
332
+ const defaultAssets = rawChainAssets.map((a) => {
333
+ var _a;
334
+ let asset;
335
+ if (a.type === 'erc20') {
336
+ const meta = a.metadata;
337
+ asset = {
229
338
  type: 'erc20',
230
- })),
231
- },
232
- })
233
- : Promise.resolve({ [hexChainId]: [] });
234
- const [defaultAssetsRaw, customAssets] = await Promise.all([defaultAssetsPromise, customAssetsPromise]);
235
- // ERC-7811 response keys may be hex (e.g. "0x14a34") or numeric depending on the RPC
236
- const rawByChain = defaultAssetsRaw;
237
- const customByChain = customAssets;
238
- const rawChainAssets = (_o = (_m = rawByChain[hexChainId]) !== null && _m !== void 0 ? _m : rawByChain[String(chainId)]) !== null && _o !== void 0 ? _o : [];
239
- const customChainAssets = (_q = (_p = customByChain[hexChainId]) !== null && _p !== void 0 ? _p : customByChain[String(chainId)]) !== null && _q !== void 0 ? _q : [];
240
- const defaultAssets = rawChainAssets.map((a) => {
241
- var _a;
242
- let asset;
243
- if (a.type === 'erc20') {
244
- const meta = a.metadata;
245
- asset = {
246
- type: 'erc20',
247
- address: a.address,
248
- balance: a.balance,
249
- metadata: {
250
- name: (meta === null || meta === void 0 ? void 0 : meta.name) || 'Unknown Token',
251
- symbol: (meta === null || meta === void 0 ? void 0 : meta.symbol) || 'UNKNOWN',
252
- decimals: meta === null || meta === void 0 ? void 0 : meta.decimals,
253
- fiat: meta === null || meta === void 0 ? void 0 : meta.fiat,
339
+ address: a.address,
340
+ balance: a.balance,
341
+ metadata: {
342
+ name: (meta === null || meta === void 0 ? void 0 : meta.name) || 'Unknown Token',
343
+ symbol: (meta === null || meta === void 0 ? void 0 : meta.symbol) || 'UNKNOWN',
344
+ decimals: meta === null || meta === void 0 ? void 0 : meta.decimals,
345
+ fiat: meta === null || meta === void 0 ? void 0 : meta.fiat,
346
+ },
347
+ raw: a,
348
+ };
349
+ }
350
+ else if (a.type === 'native') {
351
+ const meta = a.metadata;
352
+ asset = {
353
+ type: 'native',
354
+ address: 'native',
355
+ balance: a.balance,
356
+ metadata: (meta === null || meta === void 0 ? void 0 : meta.fiat)
357
+ ? { symbol: (_a = meta.symbol) !== null && _a !== void 0 ? _a : '', decimals: meta.decimals, fiat: meta.fiat }
358
+ : undefined,
359
+ raw: a,
360
+ };
361
+ }
362
+ else {
363
+ throw new OpenfortError('Unsupported asset type', OpenfortReactErrorType.UNEXPECTED_ERROR, { error: a });
364
+ }
365
+ return asset;
366
+ });
367
+ const mergedAssets = [...defaultAssets];
368
+ const customAssetsForChain = customChainAssets.flatMap((asset) => {
369
+ var _a, _b;
370
+ if (asset.type !== 'erc20')
371
+ return [];
372
+ if (!((_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.assets))
373
+ return [{ ...asset, raw: asset }];
374
+ const configAsset = (_b = walletConfig.ethereum.assets[chainId]) === null || _b === void 0 ? void 0 : _b.find((a) => a.toLowerCase() === asset.address.toLowerCase());
375
+ if (!configAsset)
376
+ return [{ ...asset, raw: asset }];
377
+ return [
378
+ {
379
+ type: 'erc20',
380
+ address: asset.address,
381
+ balance: asset.balance,
382
+ metadata: asset.metadata,
383
+ raw: asset,
254
384
  },
255
- raw: a,
256
- };
257
- }
258
- else if (a.type === 'native') {
259
- const meta = a.metadata;
260
- asset = {
261
- type: 'native',
262
- address: 'native',
263
- balance: a.balance,
264
- metadata: (meta === null || meta === void 0 ? void 0 : meta.fiat) ? { symbol: (_a = meta.symbol) !== null && _a !== void 0 ? _a : '', decimals: meta.decimals, fiat: meta.fiat } : undefined,
265
- raw: a,
266
- };
267
- }
268
- else {
269
- throw new OpenfortError('Unsupported asset type', OpenfortReactErrorType.UNEXPECTED_ERROR, { error: a });
270
- }
271
- return asset;
272
- });
273
- const mergedAssets = [...defaultAssets];
274
- const customAssetsForChain = customChainAssets.flatMap((asset) => {
275
- var _a, _b;
276
- if (asset.type !== 'erc20')
277
- return [];
278
- if (!((_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.assets))
279
- return [{ ...asset, raw: asset }];
280
- const configAsset = (_b = walletConfig.ethereum.assets[chainId]) === null || _b === void 0 ? void 0 : _b.find((a) => a.toLowerCase() === asset.address.toLowerCase());
281
- if (!configAsset)
282
- return [{ ...asset, raw: asset }];
283
- return [
284
- {
285
- type: 'erc20',
286
- address: asset.address,
287
- balance: asset.balance,
288
- metadata: asset.metadata,
289
- raw: asset,
290
- },
291
- ];
292
- });
293
- customAssetsForChain.forEach((asset) => {
294
- if (!mergedAssets.find((a) => a.address === asset.address)) {
295
- mergedAssets.push(asset);
385
+ ];
386
+ });
387
+ customAssetsForChain.forEach((asset) => {
388
+ if (!mergedAssets.find((a) => a.address === asset.address)) {
389
+ mergedAssets.push(asset);
390
+ }
391
+ });
392
+ if (mergedAssets.length === 0 && customAssetsToFetch.length > 0) {
393
+ // Proxy succeeded but returned nothing while we expect tokens — read direct.
394
+ const rpcUrl = (_z = (_y = (_x = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _x === void 0 ? void 0 : _x.rpcUrls) === null || _y === void 0 ? void 0 : _y[chainId]) !== null && _z !== void 0 ? _z : getDefaultEthereumRpcUrl(chainId);
395
+ const fb = await readEvmAssetsViaRpc({
396
+ address: address,
397
+ chain,
398
+ rpcUrl,
399
+ tokens: customAssetsToFetch,
400
+ });
401
+ if (fb.length > 0)
402
+ return fb;
296
403
  }
297
- });
298
- return mergedAssets;
404
+ return mergedAssets;
405
+ }
406
+ catch {
407
+ // ERC-7811 asset proxy failed — fall back to direct chain-RPC balance reads.
408
+ const rpcUrl = (_2 = (_1 = (_0 = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _0 === void 0 ? void 0 : _0.rpcUrls) === null || _1 === void 0 ? void 0 : _1[chainId]) !== null && _2 !== void 0 ? _2 : getDefaultEthereumRpcUrl(chainId);
409
+ return (await readEvmAssetsViaRpc({
410
+ address: address,
411
+ chain,
412
+ rpcUrl,
413
+ tokens: customAssetsToFetch,
414
+ }));
415
+ }
299
416
  },
300
417
  enabled: multiChain ? isConnected && !!address : isConnected && !!chainId && !!chain && !!address,
301
418
  staleTime,
@@ -1 +1 @@
1
- {"version":3,"file":"useEthereumWalletAssets.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useEthereumWalletAssets.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}