tiwiflix-wallet-connector 1.5.0 → 1.5.2

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/index.esm.js CHANGED
@@ -6460,7 +6460,7 @@ const BaseModal = ({ isOpen, onClose, title, children, modalPosition = 'bottom',
6460
6460
  return modalContent;
6461
6461
  };
6462
6462
 
6463
- const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAddress, onOpenSwap, onOpenSend, onOpenActivity, balance, balanceLoading, twcBalance, usdValue, nftCount = 0, nftLoading = false, tonBalance = null, tonUsdValue = null, walletIcon, colors, isDarkMode, modalPosition = 'bottom', }) => {
6463
+ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAddress, onOpenSwap, onOpenSend, onOpenActivity, balance, balanceLoading, twcBalance, usdValue, nftCount = 0, nftLoading = false, tonBalance = null, tonUsdValue = null, walletIcon, colors, isDarkMode, modalPosition = 'bottom', onSwitchWallet, }) => {
6464
6464
  // State for TWC price - hooks must be called before any conditional returns
6465
6465
  const [twcPrice, setTwcPrice] = useState(null);
6466
6466
  const [priceLoading, setPriceLoading] = useState(false);
@@ -7502,7 +7502,19 @@ const defaultStyles = {
7502
7502
  fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
7503
7503
  boxShadow: '0 4px 14px 0 rgba(51, 150, 255, 0.39)',
7504
7504
  }};
7505
- const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet', fetchTransactions, getExplorerUrl, fetchBalance, }) => {
7505
+ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet', fetchTransactions, getExplorerUrl, fetchBalance: fetchBalanceProp, }) => {
7506
+ // Provide a default fetchBalance if not passed
7507
+ const fetchBalance = fetchBalanceProp || (async (account) => {
7508
+ // Default: return zero balance with symbol based on chain
7509
+ let symbol = 'TWC';
7510
+ if (account?.chainType === 'ton')
7511
+ symbol = 'TON';
7512
+ if (account?.chainType === 'solana')
7513
+ symbol = 'SOL';
7514
+ if (account?.chainType === 'tron')
7515
+ symbol = 'TRX';
7516
+ return { amount: '0', symbol };
7517
+ });
7506
7518
  // Detect dark mode
7507
7519
  const [isDarkMode, setIsDarkMode] = useState(false);
7508
7520
  useEffect(() => {
@@ -8503,6 +8515,12 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8503
8515
  setIsConnecting(false);
8504
8516
  }
8505
8517
  catch (err) {
8518
+ // Always clear connection state on error
8519
+ setAccount(null);
8520
+ setStatus(ConnectionStatus.DISCONNECTED);
8521
+ setIsInitializing(false);
8522
+ setIsConnecting(false);
8523
+ setShowModal(false);
8506
8524
  // Close modal if the user explicitly cancelled the connection
8507
8525
  const message = err instanceof Error ? err.message : String(err);
8508
8526
  const isUserCancellation = message.toLowerCase().includes('cancelled') ||
@@ -8513,22 +8531,11 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8513
8531
  message.toLowerCase().includes('rejected') ||
8514
8532
  message.toLowerCase().includes('modal closed by user') ||
8515
8533
  message.toLowerCase().includes('connection cancelled by user');
8516
- if (isUserCancellation) {
8517
- setShowModal(false);
8518
- // Reset connecting state and verify actual connection status
8519
- const actualAccount = await connector.getAccount();
8520
- if (!actualAccount) {
8521
- setAccount(null);
8522
- }
8523
- }
8524
- else if (isTonWallet) {
8534
+ if (!isUserCancellation && isTonWallet) {
8525
8535
  // For TON, only reopen the modal on non-cancellation errors
8526
8536
  setShowModal(true);
8527
8537
  }
8528
8538
  }
8529
- finally {
8530
- setIsConnecting(false);
8531
- }
8532
8539
  }, [connector, fetchBalance, loadBalance]);
8533
8540
  const handleDisconnect = useCallback(async () => {
8534
8541
  try {
@@ -8592,24 +8599,36 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8592
8599
  setError('Failed to switch network. Please switch manually to BSC in your wallet.');
8593
8600
  }
8594
8601
  }, [connector]);
8595
- const handleOpenModal = useCallback(() => {
8602
+ // Only open wallet selection modal if not connected, or if explicitly switching
8603
+ const handleOpenModal = useCallback((force = false) => {
8604
+ // If already connected and not explicitly switching, do nothing
8605
+ const state = connector.getState();
8606
+ if (!force && account && state.status === 'connected') {
8607
+ return;
8608
+ }
8596
8609
  // Show ALL wallets - use cached wallets to prevent re-renders
8597
8610
  if (!walletsRef.current) {
8598
8611
  walletsRef.current = connector.getAllWallets();
8599
8612
  }
8600
8613
  setAvailableWallets(walletsRef.current);
8601
8614
  setShowModal(true);
8602
- }, [connector]);
8615
+ }, [connector, account]);
8603
8616
  // Render button based on connection status
8604
8617
  const renderButton = () => {
8605
8618
  // Check if we're waiting for connection OR waiting for balance to load
8606
8619
  // Show loading if: initializing, connecting, OR (account exists but balance hasn't loaded/resolved yet)
8607
- // Treat "0", "0.00" or empty as "not loaded yet" - only show connected state when we have real (non-zero) balance
8608
- const hasRealBalance = (balance.amount && balance.amount !== '0' && balance.amount !== '0.00' && balance.amount !== '' && balance.amount !== 'Loading...') ||
8620
+ // For TON: treat as resolved after fetch completes (even if 0). For others: treat zero/empty as resolved.
8621
+ (balance.amount && balance.amount !== '0' && balance.amount !== '0.00' && balance.amount !== '' && balance.amount !== 'Loading...') ||
8609
8622
  (twcBalance && twcBalance !== '0' && twcBalance !== '0.00' && twcBalance !== '' && twcBalance !== 'Loading...');
8610
- // For TON wallets, balance is resolved after fetch completes (even if empty/0)
8611
- // For other wallets, balance is resolved only if we have a real (non-zero) balance
8612
- const isBalanceResolved = !balanceLoading && (hasRealBalance || (account?.chainType === 'ton' && !isInitializing));
8623
+ let isBalanceResolved;
8624
+ if (account?.chainType === 'ton') {
8625
+ // For TON, resolved if not loading or initializing
8626
+ isBalanceResolved = !balanceLoading && !isInitializing;
8627
+ }
8628
+ else {
8629
+ // For EVM, Solana, Tron: resolved if not loading (even if balance is zero)
8630
+ isBalanceResolved = !balanceLoading && !isInitializing;
8631
+ }
8613
8632
  const waitingForBalance = account && !isBalanceResolved;
8614
8633
  const isCheckingConnection = isInitializing || waitingForBalance || ((status === ConnectionStatus.CONNECTING || isConnecting) && !account);
8615
8634
  const isActuallyConnecting = (status === ConnectionStatus.CONNECTING || isConnecting) && account && isBalanceResolved;
@@ -8820,31 +8839,34 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8820
8839
  }
8821
8840
  // Wallet icon SVG component
8822
8841
  const WalletIcon = () => (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { display: 'block' }, children: [jsx("path", { d: "M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" }), jsx("path", { d: "M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" })] }));
8823
- return (jsxs("button", { onClick: handleOpenModal, style: {
8824
- display: 'flex',
8825
- alignItems: 'center',
8826
- gap: '10px',
8827
- padding: '12px 12px',
8828
- borderRadius: '12px',
8829
- border: 'none',
8830
- backgroundColor: '#FF9814', // Warm golden-orange
8831
- color: '#000000', // Black text
8832
- fontWeight: '700',
8833
- fontSize: '15px',
8834
- cursor: 'pointer',
8835
- transition: 'all 0.15s ease',
8836
- fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8837
- boxShadow: '0 2px 8px rgba(255, 152, 20, 0.3)',
8838
- ...style,
8839
- }, className: className, onMouseEnter: (e) => {
8840
- e.currentTarget.style.backgroundColor = '#E8870F';
8841
- e.currentTarget.style.transform = 'translateY(-1px)';
8842
- e.currentTarget.style.boxShadow = '0 4px 12px rgba(255, 152, 20, 0.4)';
8843
- }, onMouseLeave: (e) => {
8844
- e.currentTarget.style.backgroundColor = '#FF9814';
8845
- e.currentTarget.style.transform = 'translateY(0)';
8846
- e.currentTarget.style.boxShadow = '0 2px 8px rgba(255, 152, 20, 0.3)';
8847
- }, children: [jsx("span", { style: { color: '#000000', display: 'flex', alignItems: 'center' }, children: jsx(WalletIcon, {}) }), jsx("span", { style: { color: '#000000', fontWeight: '500', fontSize: '14px' }, children: buttonText })] }));
8842
+ // Only show connect button if not connected
8843
+ if (!account || status !== ConnectionStatus.CONNECTED) {
8844
+ return (jsxs("button", { onClick: () => handleOpenModal(), style: {
8845
+ display: 'flex',
8846
+ alignItems: 'center',
8847
+ gap: '10px',
8848
+ padding: '12px 12px',
8849
+ borderRadius: '12px',
8850
+ border: 'none',
8851
+ backgroundColor: '#FF9814', // Warm golden-orange
8852
+ color: '#000000', // Black text
8853
+ fontWeight: '700',
8854
+ fontSize: '15px',
8855
+ cursor: 'pointer',
8856
+ transition: 'all 0.15s ease',
8857
+ fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8858
+ boxShadow: '0 2px 8px rgba(255, 152, 20, 0.3)',
8859
+ ...style,
8860
+ }, className: className, onMouseEnter: (e) => {
8861
+ e.currentTarget.style.backgroundColor = '#E8870F';
8862
+ e.currentTarget.style.transform = 'translateY(-1px)';
8863
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(255, 152, 20, 0.4)';
8864
+ }, onMouseLeave: (e) => {
8865
+ e.currentTarget.style.backgroundColor = '#FF9814';
8866
+ e.currentTarget.style.transform = 'translateY(0)';
8867
+ e.currentTarget.style.boxShadow = '0 2px 8px rgba(255, 152, 20, 0.3)';
8868
+ }, children: [jsx("span", { style: { color: '#000000', display: 'flex', alignItems: 'center' }, children: jsx(WalletIcon, {}) }), jsx("span", { style: { color: '#000000', fontWeight: '500', fontSize: '14px' }, children: buttonText })] }));
8869
+ }
8848
8870
  };
8849
8871
  // Group wallets by chain
8850
8872
  availableWallets.reduce((acc, wallet) => {
@@ -8863,7 +8885,9 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8863
8885
  .tiwiflix-scrollbar-hide::-webkit-scrollbar {
8864
8886
  display: none;
8865
8887
  }
8866
- ` }), renderButton(), jsx(AccountDetailsModal, { isOpen: showDetailsModal, onClose: () => setShowDetailsModal(false), account: account, onDisconnect: handleDisconnect, onCopyAddress: handleCopyAddress, onOpenSwap: () => setShowSwapModal(true), onOpenSend: () => setShowSendModal(true), onOpenActivity: () => setShowActivityModal(true), balance: balance, balanceLoading: balanceLoading, twcBalance: twcBalance, usdValue: usdValue, nftCount: nftCount, nftLoading: nftLoading, tonBalance: balance.amount || tonBalance, tonUsdValue: balance.usdValue ?? tonUsdValue, walletIcon: walletIcon, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsx(ActivityModal, { isOpen: showActivityModal, onClose: () => setShowActivityModal(false), transactions: txs, loading: txsLoading, error: txsError, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsx(SwapModal, { isOpen: showSwapModal && account?.chainType !== 'ton', onClose: () => setShowSwapModal(false), colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsx(SendModal, { isOpen: showSendModal, onClose: () => setShowSendModal(false), balance: balance, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition, onSend: async () => {
8888
+ ` }), renderButton(), jsx(AccountDetailsModal, { isOpen: showDetailsModal, onClose: () => setShowDetailsModal(false), account: account, onDisconnect: handleDisconnect, onCopyAddress: handleCopyAddress, onOpenSwap: () => setShowSwapModal(true), onOpenSend: () => setShowSendModal(true), onOpenActivity: () => setShowActivityModal(true), balance: balance, balanceLoading: balanceLoading, twcBalance: twcBalance, usdValue: usdValue, nftCount: nftCount, nftLoading: nftLoading, tonBalance: balance.amount || tonBalance, tonUsdValue: balance.usdValue ?? tonUsdValue, walletIcon: walletIcon, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition,
8889
+ // Add a Switch Wallet button to allow explicit wallet switching
8890
+ onSwitchWallet: () => handleOpenModal(true) }), jsx(ActivityModal, { isOpen: showActivityModal, onClose: () => setShowActivityModal(false), transactions: txs, loading: txsLoading, error: txsError, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsx(SwapModal, { isOpen: showSwapModal && account?.chainType !== 'ton', onClose: () => setShowSwapModal(false), colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsx(SendModal, { isOpen: showSendModal, onClose: () => setShowSendModal(false), balance: balance, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition, onSend: async () => {
8867
8891
  alert('Send functionality coming soon');
8868
8892
  setShowSendModal(false);
8869
8893
  } }), jsx(TWCBalanceModal, { isOpen: showTWCBalanceModal, onClose: () => setShowTWCBalanceModal(false), twcBalance: twcBalance, usdValue: usdValue, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition, onBuyTWC: () => {
package/dist/index.js CHANGED
@@ -6462,7 +6462,7 @@ const BaseModal = ({ isOpen, onClose, title, children, modalPosition = 'bottom',
6462
6462
  return modalContent;
6463
6463
  };
6464
6464
 
6465
- const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAddress, onOpenSwap, onOpenSend, onOpenActivity, balance, balanceLoading, twcBalance, usdValue, nftCount = 0, nftLoading = false, tonBalance = null, tonUsdValue = null, walletIcon, colors, isDarkMode, modalPosition = 'bottom', }) => {
6465
+ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAddress, onOpenSwap, onOpenSend, onOpenActivity, balance, balanceLoading, twcBalance, usdValue, nftCount = 0, nftLoading = false, tonBalance = null, tonUsdValue = null, walletIcon, colors, isDarkMode, modalPosition = 'bottom', onSwitchWallet, }) => {
6466
6466
  // State for TWC price - hooks must be called before any conditional returns
6467
6467
  const [twcPrice, setTwcPrice] = React.useState(null);
6468
6468
  const [priceLoading, setPriceLoading] = React.useState(false);
@@ -7504,7 +7504,19 @@ const defaultStyles = {
7504
7504
  fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
7505
7505
  boxShadow: '0 4px 14px 0 rgba(51, 150, 255, 0.39)',
7506
7506
  }};
7507
- const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet', fetchTransactions, getExplorerUrl, fetchBalance, }) => {
7507
+ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet', fetchTransactions, getExplorerUrl, fetchBalance: fetchBalanceProp, }) => {
7508
+ // Provide a default fetchBalance if not passed
7509
+ const fetchBalance = fetchBalanceProp || (async (account) => {
7510
+ // Default: return zero balance with symbol based on chain
7511
+ let symbol = 'TWC';
7512
+ if (account?.chainType === 'ton')
7513
+ symbol = 'TON';
7514
+ if (account?.chainType === 'solana')
7515
+ symbol = 'SOL';
7516
+ if (account?.chainType === 'tron')
7517
+ symbol = 'TRX';
7518
+ return { amount: '0', symbol };
7519
+ });
7508
7520
  // Detect dark mode
7509
7521
  const [isDarkMode, setIsDarkMode] = React.useState(false);
7510
7522
  React.useEffect(() => {
@@ -8505,6 +8517,12 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8505
8517
  setIsConnecting(false);
8506
8518
  }
8507
8519
  catch (err) {
8520
+ // Always clear connection state on error
8521
+ setAccount(null);
8522
+ setStatus(exports.ConnectionStatus.DISCONNECTED);
8523
+ setIsInitializing(false);
8524
+ setIsConnecting(false);
8525
+ setShowModal(false);
8508
8526
  // Close modal if the user explicitly cancelled the connection
8509
8527
  const message = err instanceof Error ? err.message : String(err);
8510
8528
  const isUserCancellation = message.toLowerCase().includes('cancelled') ||
@@ -8515,22 +8533,11 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8515
8533
  message.toLowerCase().includes('rejected') ||
8516
8534
  message.toLowerCase().includes('modal closed by user') ||
8517
8535
  message.toLowerCase().includes('connection cancelled by user');
8518
- if (isUserCancellation) {
8519
- setShowModal(false);
8520
- // Reset connecting state and verify actual connection status
8521
- const actualAccount = await connector.getAccount();
8522
- if (!actualAccount) {
8523
- setAccount(null);
8524
- }
8525
- }
8526
- else if (isTonWallet) {
8536
+ if (!isUserCancellation && isTonWallet) {
8527
8537
  // For TON, only reopen the modal on non-cancellation errors
8528
8538
  setShowModal(true);
8529
8539
  }
8530
8540
  }
8531
- finally {
8532
- setIsConnecting(false);
8533
- }
8534
8541
  }, [connector, fetchBalance, loadBalance]);
8535
8542
  const handleDisconnect = React.useCallback(async () => {
8536
8543
  try {
@@ -8594,24 +8601,36 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8594
8601
  setError('Failed to switch network. Please switch manually to BSC in your wallet.');
8595
8602
  }
8596
8603
  }, [connector]);
8597
- const handleOpenModal = React.useCallback(() => {
8604
+ // Only open wallet selection modal if not connected, or if explicitly switching
8605
+ const handleOpenModal = React.useCallback((force = false) => {
8606
+ // If already connected and not explicitly switching, do nothing
8607
+ const state = connector.getState();
8608
+ if (!force && account && state.status === 'connected') {
8609
+ return;
8610
+ }
8598
8611
  // Show ALL wallets - use cached wallets to prevent re-renders
8599
8612
  if (!walletsRef.current) {
8600
8613
  walletsRef.current = connector.getAllWallets();
8601
8614
  }
8602
8615
  setAvailableWallets(walletsRef.current);
8603
8616
  setShowModal(true);
8604
- }, [connector]);
8617
+ }, [connector, account]);
8605
8618
  // Render button based on connection status
8606
8619
  const renderButton = () => {
8607
8620
  // Check if we're waiting for connection OR waiting for balance to load
8608
8621
  // Show loading if: initializing, connecting, OR (account exists but balance hasn't loaded/resolved yet)
8609
- // Treat "0", "0.00" or empty as "not loaded yet" - only show connected state when we have real (non-zero) balance
8610
- const hasRealBalance = (balance.amount && balance.amount !== '0' && balance.amount !== '0.00' && balance.amount !== '' && balance.amount !== 'Loading...') ||
8622
+ // For TON: treat as resolved after fetch completes (even if 0). For others: treat zero/empty as resolved.
8623
+ (balance.amount && balance.amount !== '0' && balance.amount !== '0.00' && balance.amount !== '' && balance.amount !== 'Loading...') ||
8611
8624
  (twcBalance && twcBalance !== '0' && twcBalance !== '0.00' && twcBalance !== '' && twcBalance !== 'Loading...');
8612
- // For TON wallets, balance is resolved after fetch completes (even if empty/0)
8613
- // For other wallets, balance is resolved only if we have a real (non-zero) balance
8614
- const isBalanceResolved = !balanceLoading && (hasRealBalance || (account?.chainType === 'ton' && !isInitializing));
8625
+ let isBalanceResolved;
8626
+ if (account?.chainType === 'ton') {
8627
+ // For TON, resolved if not loading or initializing
8628
+ isBalanceResolved = !balanceLoading && !isInitializing;
8629
+ }
8630
+ else {
8631
+ // For EVM, Solana, Tron: resolved if not loading (even if balance is zero)
8632
+ isBalanceResolved = !balanceLoading && !isInitializing;
8633
+ }
8615
8634
  const waitingForBalance = account && !isBalanceResolved;
8616
8635
  const isCheckingConnection = isInitializing || waitingForBalance || ((status === exports.ConnectionStatus.CONNECTING || isConnecting) && !account);
8617
8636
  const isActuallyConnecting = (status === exports.ConnectionStatus.CONNECTING || isConnecting) && account && isBalanceResolved;
@@ -8822,31 +8841,34 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8822
8841
  }
8823
8842
  // Wallet icon SVG component
8824
8843
  const WalletIcon = () => (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { display: 'block' }, children: [jsxRuntime.jsx("path", { d: "M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" }), jsxRuntime.jsx("path", { d: "M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" })] }));
8825
- return (jsxRuntime.jsxs("button", { onClick: handleOpenModal, style: {
8826
- display: 'flex',
8827
- alignItems: 'center',
8828
- gap: '10px',
8829
- padding: '12px 12px',
8830
- borderRadius: '12px',
8831
- border: 'none',
8832
- backgroundColor: '#FF9814', // Warm golden-orange
8833
- color: '#000000', // Black text
8834
- fontWeight: '700',
8835
- fontSize: '15px',
8836
- cursor: 'pointer',
8837
- transition: 'all 0.15s ease',
8838
- fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8839
- boxShadow: '0 2px 8px rgba(255, 152, 20, 0.3)',
8840
- ...style,
8841
- }, className: className, onMouseEnter: (e) => {
8842
- e.currentTarget.style.backgroundColor = '#E8870F';
8843
- e.currentTarget.style.transform = 'translateY(-1px)';
8844
- e.currentTarget.style.boxShadow = '0 4px 12px rgba(255, 152, 20, 0.4)';
8845
- }, onMouseLeave: (e) => {
8846
- e.currentTarget.style.backgroundColor = '#FF9814';
8847
- e.currentTarget.style.transform = 'translateY(0)';
8848
- e.currentTarget.style.boxShadow = '0 2px 8px rgba(255, 152, 20, 0.3)';
8849
- }, children: [jsxRuntime.jsx("span", { style: { color: '#000000', display: 'flex', alignItems: 'center' }, children: jsxRuntime.jsx(WalletIcon, {}) }), jsxRuntime.jsx("span", { style: { color: '#000000', fontWeight: '500', fontSize: '14px' }, children: buttonText })] }));
8844
+ // Only show connect button if not connected
8845
+ if (!account || status !== exports.ConnectionStatus.CONNECTED) {
8846
+ return (jsxRuntime.jsxs("button", { onClick: () => handleOpenModal(), style: {
8847
+ display: 'flex',
8848
+ alignItems: 'center',
8849
+ gap: '10px',
8850
+ padding: '12px 12px',
8851
+ borderRadius: '12px',
8852
+ border: 'none',
8853
+ backgroundColor: '#FF9814', // Warm golden-orange
8854
+ color: '#000000', // Black text
8855
+ fontWeight: '700',
8856
+ fontSize: '15px',
8857
+ cursor: 'pointer',
8858
+ transition: 'all 0.15s ease',
8859
+ fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8860
+ boxShadow: '0 2px 8px rgba(255, 152, 20, 0.3)',
8861
+ ...style,
8862
+ }, className: className, onMouseEnter: (e) => {
8863
+ e.currentTarget.style.backgroundColor = '#E8870F';
8864
+ e.currentTarget.style.transform = 'translateY(-1px)';
8865
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(255, 152, 20, 0.4)';
8866
+ }, onMouseLeave: (e) => {
8867
+ e.currentTarget.style.backgroundColor = '#FF9814';
8868
+ e.currentTarget.style.transform = 'translateY(0)';
8869
+ e.currentTarget.style.boxShadow = '0 2px 8px rgba(255, 152, 20, 0.3)';
8870
+ }, children: [jsxRuntime.jsx("span", { style: { color: '#000000', display: 'flex', alignItems: 'center' }, children: jsxRuntime.jsx(WalletIcon, {}) }), jsxRuntime.jsx("span", { style: { color: '#000000', fontWeight: '500', fontSize: '14px' }, children: buttonText })] }));
8871
+ }
8850
8872
  };
8851
8873
  // Group wallets by chain
8852
8874
  availableWallets.reduce((acc, wallet) => {
@@ -8865,7 +8887,9 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8865
8887
  .tiwiflix-scrollbar-hide::-webkit-scrollbar {
8866
8888
  display: none;
8867
8889
  }
8868
- ` }), renderButton(), jsxRuntime.jsx(AccountDetailsModal, { isOpen: showDetailsModal, onClose: () => setShowDetailsModal(false), account: account, onDisconnect: handleDisconnect, onCopyAddress: handleCopyAddress, onOpenSwap: () => setShowSwapModal(true), onOpenSend: () => setShowSendModal(true), onOpenActivity: () => setShowActivityModal(true), balance: balance, balanceLoading: balanceLoading, twcBalance: twcBalance, usdValue: usdValue, nftCount: nftCount, nftLoading: nftLoading, tonBalance: balance.amount || tonBalance, tonUsdValue: balance.usdValue ?? tonUsdValue, walletIcon: walletIcon, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsxRuntime.jsx(ActivityModal, { isOpen: showActivityModal, onClose: () => setShowActivityModal(false), transactions: txs, loading: txsLoading, error: txsError, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsxRuntime.jsx(SwapModal, { isOpen: showSwapModal && account?.chainType !== 'ton', onClose: () => setShowSwapModal(false), colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsxRuntime.jsx(SendModal, { isOpen: showSendModal, onClose: () => setShowSendModal(false), balance: balance, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition, onSend: async () => {
8890
+ ` }), renderButton(), jsxRuntime.jsx(AccountDetailsModal, { isOpen: showDetailsModal, onClose: () => setShowDetailsModal(false), account: account, onDisconnect: handleDisconnect, onCopyAddress: handleCopyAddress, onOpenSwap: () => setShowSwapModal(true), onOpenSend: () => setShowSendModal(true), onOpenActivity: () => setShowActivityModal(true), balance: balance, balanceLoading: balanceLoading, twcBalance: twcBalance, usdValue: usdValue, nftCount: nftCount, nftLoading: nftLoading, tonBalance: balance.amount || tonBalance, tonUsdValue: balance.usdValue ?? tonUsdValue, walletIcon: walletIcon, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition,
8891
+ // Add a Switch Wallet button to allow explicit wallet switching
8892
+ onSwitchWallet: () => handleOpenModal(true) }), jsxRuntime.jsx(ActivityModal, { isOpen: showActivityModal, onClose: () => setShowActivityModal(false), transactions: txs, loading: txsLoading, error: txsError, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsxRuntime.jsx(SwapModal, { isOpen: showSwapModal && account?.chainType !== 'ton', onClose: () => setShowSwapModal(false), colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition }), jsxRuntime.jsx(SendModal, { isOpen: showSendModal, onClose: () => setShowSendModal(false), balance: balance, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition, onSend: async () => {
8869
8893
  alert('Send functionality coming soon');
8870
8894
  setShowSendModal(false);
8871
8895
  } }), jsxRuntime.jsx(TWCBalanceModal, { isOpen: showTWCBalanceModal, onClose: () => setShowTWCBalanceModal(false), twcBalance: twcBalance, usdValue: usdValue, colors: colors, isDarkMode: isDarkMode, modalPosition: modalPosition, onBuyTWC: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiwiflix-wallet-connector",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Multi-chain wallet connector for Tiwiflix supporting EVM, TON, Solana, and Tron wallets",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",