tiwiflix-wallet-connector 1.5.9 → 1.6.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.
package/dist/index.esm.js CHANGED
@@ -7516,20 +7516,6 @@ const TWCBalanceModal = ({ isOpen, onClose, twcBalance, usdValue, colors, isDark
7516
7516
 
7517
7517
  const tonApiCache = new Map();
7518
7518
  const CACHE_DURATION = 30000; // 30 seconds
7519
- const defaultStyles = {
7520
- button: {
7521
- padding: '10px 20px',
7522
- borderRadius: '14px',
7523
- border: 'none',
7524
- backgroundColor: '#3396FF', // This will be overridden by theme colors in actual usage
7525
- color: 'white',
7526
- fontWeight: '500',
7527
- fontSize: '14px',
7528
- cursor: 'pointer',
7529
- transition: 'all 0.15s ease',
7530
- fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
7531
- boxShadow: '0 4px 14px 0 rgba(51, 150, 255, 0.39)',
7532
- }};
7533
7519
  const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet Now', getExplorerUrl, }) => {
7534
7520
  // Always fetch balance automatically when wallet is connected
7535
7521
  // Balance is always fetched automatically from the chain
@@ -7824,7 +7810,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
7824
7810
  }, 4000); // force-resolve after 4s
7825
7811
  return () => clearTimeout(timeout);
7826
7812
  }, [isInitializing, balanceLoading, isConnecting]);
7827
- // Check chain ID and validate network
7813
+ // Remove network restriction: allow all EVM networks to connect
7828
7814
  useEffect(() => {
7829
7815
  const checkChain = async () => {
7830
7816
  if (!account || account.chainType !== 'evm') {
@@ -7835,16 +7821,13 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
7835
7821
  try {
7836
7822
  const chainId = await connector.getCurrentChain();
7837
7823
  setCurrentChainId(chainId);
7838
- // BSC Mainnet = 56, BSC Testnet = 97
7839
- const isBSC = chainId === 56 || chainId === 97;
7840
- setIsWrongNetwork(!isBSC && chainId !== null);
7824
+ // No restriction: allow all EVM networks
7825
+ setIsWrongNetwork(false);
7841
7826
  }
7842
7827
  catch (err) {
7843
7828
  }
7844
7829
  };
7845
7830
  checkChain();
7846
- // Also periodically check if still connected to EVM wallet
7847
- // This handles cases where chain is changed from wallet UI
7848
7831
  if (account && account.chainType === 'evm') {
7849
7832
  const interval = setInterval(checkChain, 2000);
7850
7833
  return () => clearInterval(interval);
@@ -8395,7 +8378,13 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8395
8378
  }
8396
8379
  }, [account]);
8397
8380
  const fetchTWCBalanceWithRetry = useCallback(async (maxRetries = 3, initialDelay = 200) => {
8381
+ // Only fetch TWC balance if wallet is on BSC (chainId 56)
8398
8382
  try {
8383
+ const state = connector.getState();
8384
+ if (state.account?.chainType !== 'evm' || state.chainId !== 56) {
8385
+ // Not on BSC, do not fetch TWC balance
8386
+ return null;
8387
+ }
8399
8388
  const twcBalance = await connector.getTWCBalance();
8400
8389
  return {
8401
8390
  balance: twcBalance.amount || '0',
@@ -8417,14 +8406,14 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8417
8406
  }
8418
8407
  return null;
8419
8408
  }, [connector]);
8420
- // Load balance when account changes
8409
+ // Load balance when account or network (chain) changes
8421
8410
  useEffect(() => {
8422
8411
  let isActive = true;
8423
8412
  // Only log and run effect if account is not null
8424
8413
  if (account) {
8425
- console.log('[ConnectButton] useEffect: account changed', { account });
8426
- // For EVM wallets, try to get TWC balance
8427
- if (account.chainType === 'evm') {
8414
+ console.log('[ConnectButton] useEffect: account or chain changed', { account, currentChainId });
8415
+ // For EVM wallets, only fetch TWC balance if on BSC
8416
+ if (account.chainType === 'evm' && currentChainId === 56) {
8428
8417
  // First check state/cache for immediate display
8429
8418
  const state = connector.getState();
8430
8419
  let hasBalance = false;
@@ -8447,9 +8436,9 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8447
8436
  hasBalance = true;
8448
8437
  }
8449
8438
  }
8450
- // Only fetch if we don't have a balance yet
8451
- if (!hasBalance) {
8452
- console.log('[ConnectButton] Fetching TWC balance for EVM wallet:', account.address);
8439
+ // Only fetch if we don't have a balance yet, or if the chain/network changed
8440
+ if (!hasBalance || currentChainId !== null) {
8441
+ console.log('[ConnectButton] Fetching TWC balance for BSC wallet:', account.address, currentChainId);
8453
8442
  fetchTWCBalanceWithRetry(2, 200).then((result) => {
8454
8443
  if (!isActive)
8455
8444
  return;
@@ -8467,16 +8456,23 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8467
8456
  setTwcBalance('0');
8468
8457
  setUsdValueStable(null);
8469
8458
  setIsInitializing(false);
8470
- console.warn('[ConnectButton] No TWC balance found for EVM wallet:', account.address);
8459
+ console.warn('[ConnectButton] No TWC balance found for BSC wallet:', account.address);
8471
8460
  }
8472
8461
  }).catch(() => {
8473
8462
  if (!isActive)
8474
8463
  return;
8475
8464
  setIsInitializing(false);
8476
- console.error('[ConnectButton] Error fetching TWC balance for EVM wallet:', account.address);
8465
+ console.error('[ConnectButton] Error fetching TWC balance for BSC wallet:', account.address);
8477
8466
  });
8478
8467
  }
8479
8468
  }
8469
+ else if (account.chainType === 'evm' && currentChainId !== 56) {
8470
+ // EVM wallet but not on BSC, do not fetch TWC balance, do not show switch chain
8471
+ setTwcBalance(null);
8472
+ setUsdValueStable(null);
8473
+ setIsInitializing(false);
8474
+ // Do not show error or prompt
8475
+ }
8480
8476
  else {
8481
8477
  // Non-EVM wallet, just check state
8482
8478
  const state = connector.getState();
@@ -8497,7 +8493,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8497
8493
  isActive = false;
8498
8494
  };
8499
8495
  // eslint-disable-next-line react-hooks/exhaustive-deps
8500
- }, [account?.address]);
8496
+ }, [account?.address, currentChainId]);
8501
8497
  // Polling mechanism as fallback to ensure TWC balance is always fetched
8502
8498
  useEffect(() => {
8503
8499
  if (!account || account.chainType !== 'evm') {
@@ -8664,7 +8660,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8664
8660
  alert('Address copied to clipboard!');
8665
8661
  }
8666
8662
  }, [account]);
8667
- const handleSwitchToBSC = useCallback(async () => {
8663
+ useCallback(async () => {
8668
8664
  try {
8669
8665
  // Try to switch to BSC Mainnet (56)
8670
8666
  await connector.switchChain(56);
@@ -8689,85 +8685,47 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8689
8685
  }, [connector, account]);
8690
8686
  // Render button based on connection status
8691
8687
  const renderButton = () => {
8692
- // Check if we're waiting for connection OR waiting for balance to load
8693
- // Show loading if: initializing, connecting, OR (account exists but balance hasn't loaded/resolved yet)
8694
- // For TON: treat as resolved after fetch completes (even if 0). For others: treat zero/empty as resolved.
8695
- (balance.amount && balance.amount !== '0' && balance.amount !== '0.00' && balance.amount !== '' && balance.amount !== 'Loading...') ||
8696
- (twcBalance && twcBalance !== '0' && twcBalance !== '0.00' && twcBalance !== '' && twcBalance !== 'Loading...');
8697
- // Treat balance loading as background; only gate on initial connection.
8698
- const isCheckingConnection = isInitializing || ((status === ConnectionStatus.CONNECTING || isConnecting) && !account);
8699
- const isActuallyConnecting = (status === ConnectionStatus.CONNECTING || isConnecting) && !!account && !isInitializing;
8700
- // Check connection state
8701
- if (isCheckingConnection) {
8702
- // Show loading connected button structure while checking connection
8703
- const isMobile = isMobileViewport();
8704
- // Loading spinner component
8705
- const LoadingSpinner = () => (jsxs(Fragment, { children: [jsx("div", { style: {
8706
- width: isMobile ? '12px' : '14px',
8707
- height: isMobile ? '12px' : '14px',
8708
- border: '2px solid rgba(255, 255, 255, 0.3)',
8709
- borderTopColor: '#FFFFFF',
8710
- borderRadius: '50%',
8711
- animation: 'spin 0.8s linear infinite',
8712
- } }), jsx("style", { children: `
8713
- @keyframes spin {
8714
- to { transform: rotate(360deg); }
8715
- }
8716
- ` })] }));
8717
- return (jsx("button", { onClick: () => setShowDetailsModal(false), style: {
8688
+ // Only show connect button if we are fully initialized and truly disconnected
8689
+ if (!isInitializing && (!account || status === ConnectionStatus.DISCONNECTED)) {
8690
+ // Wallet icon SVG component
8691
+ 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" })] }));
8692
+ return (jsxs("button", { onClick: () => handleOpenModal(), style: {
8718
8693
  display: 'flex',
8719
8694
  alignItems: 'center',
8720
- justifyContent: 'space-between',
8721
- padding: isMobile ? '4px 4px' : '6px 6px',
8722
- borderRadius: '50px',
8695
+ gap: '10px',
8696
+ padding: '12px 12px',
8697
+ borderRadius: '12px',
8723
8698
  border: 'none',
8724
- background: '#2A2A2A',
8725
- minWidth: isMobile ? '160px' : '320px',
8726
- maxWidth: isMobile ? '100%' : undefined,
8727
- cursor: 'default',
8699
+ backgroundColor: '#FF9814',
8700
+ color: '#000000',
8701
+ fontWeight: '700',
8702
+ fontSize: '15px',
8703
+ cursor: 'pointer',
8704
+ transition: 'all 0.15s ease',
8728
8705
  fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8706
+ boxShadow: '0 2px 8px rgba(255, 152, 20, 0.3)',
8729
8707
  ...style,
8730
- }, className: className, disabled: true, children: jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: isMobile ? '6px' : '10px', flex: '1', minWidth: 0, padding: isMobile ? '4px' : '8px' }, children: [twcIconMemoized, jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: isMobile ? '4px' : '6px', minWidth: 0 }, children: [jsx(LoadingSpinner, {}), jsx("div", { style: {
8731
- fontSize: isMobile ? '11px' : '12px',
8732
- fontWeight: '400',
8733
- color: '#FFFFFF',
8734
- fontFamily: 'Lexend, sans-serif',
8735
- }, children: "Loading..." }), jsx("div", { style: {
8736
- fontSize: isMobile ? '11px' : '12px',
8737
- fontWeight: '400',
8738
- color: '#FFFFFF',
8739
- fontFamily: 'Lexend, sans-serif',
8740
- flexShrink: 0,
8741
- }, children: "TWC" })] })] }) }));
8708
+ }, className: className, onMouseEnter: (e) => {
8709
+ e.currentTarget.style.backgroundColor = '#E8870F';
8710
+ e.currentTarget.style.transform = 'translateY(-1px)';
8711
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(255, 152, 20, 0.4)';
8712
+ }, onMouseLeave: (e) => {
8713
+ e.currentTarget.style.backgroundColor = '#FF9814';
8714
+ e.currentTarget.style.transform = 'translateY(0)';
8715
+ e.currentTarget.style.boxShadow = '0 2px 8px rgba(255, 152, 20, 0.3)';
8716
+ }, children: [jsx("span", { style: { color: '#000000', display: 'flex', alignItems: 'center' }, children: jsx(WalletIcon, {}) }), jsx("span", { style: { color: '#000000', fontWeight: '500', fontSize: '14px' }, children: buttonText })] }));
8742
8717
  }
8743
- if (isActuallyConnecting) {
8744
- return (jsx("button", { style: { ...defaultStyles.button, opacity: 0.7, ...style }, className: className, disabled: true, children: "\u23F3 Connecting..." }));
8718
+ // ...existing code...
8719
+ // All other states (including loading, connecting, connected) should only show the connected button or loading spinner if account is present or initializing is true
8720
+ // If initializing, show nothing (or a spinner if desired)
8721
+ if (isInitializing) {
8722
+ // Optionally, you can show a spinner or skeleton here, but do not show connect/disconnect buttons
8723
+ return null;
8745
8724
  }
8725
+ // ...existing code...
8726
+ // The rest of the renderButton logic (wrong network, connected, etc.) remains unchanged
8746
8727
  if (account) {
8747
- // Show "Wrong Network" button if connected to non-BSC network
8748
- if (isWrongNetwork) {
8749
- return (jsx("button", { onClick: handleSwitchToBSC, style: {
8750
- padding: '10px 16px',
8751
- borderRadius: '16px',
8752
- border: 'none',
8753
- backgroundColor: '#F59E0B',
8754
- display: 'flex',
8755
- alignItems: 'center',
8756
- gap: '10px',
8757
- cursor: 'pointer',
8758
- transition: 'all 0.15s ease',
8759
- fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8760
- ...style,
8761
- }, className: className, onMouseEnter: (e) => {
8762
- e.currentTarget.style.backgroundColor = '#D97706';
8763
- e.currentTarget.style.transform = 'translateY(-1px)';
8764
- e.currentTarget.style.boxShadow = '0 4px 12px rgba(245, 158, 11, 0.4)';
8765
- }, onMouseLeave: (e) => {
8766
- e.currentTarget.style.backgroundColor = '#F59E0B';
8767
- e.currentTarget.style.transform = 'translateY(0)';
8768
- e.currentTarget.style.boxShadow = 'none';
8769
- }, children: jsx("span", { style: { fontSize: '13px', fontWeight: '600', color: 'white' }, children: "\uD83D\uDD04 Switch to BSC" }) }));
8770
- }
8728
+ // ...existing code...
8771
8729
  // Show normal connected button - styled to match design
8772
8730
  // Parse balance amount and symbol separately
8773
8731
  // For TON: show TON balance (not TWC, not NFT count in button)
package/dist/index.js CHANGED
@@ -7518,20 +7518,6 @@ const TWCBalanceModal = ({ isOpen, onClose, twcBalance, usdValue, colors, isDark
7518
7518
 
7519
7519
  const tonApiCache = new Map();
7520
7520
  const CACHE_DURATION = 30000; // 30 seconds
7521
- const defaultStyles = {
7522
- button: {
7523
- padding: '10px 20px',
7524
- borderRadius: '14px',
7525
- border: 'none',
7526
- backgroundColor: '#3396FF', // This will be overridden by theme colors in actual usage
7527
- color: 'white',
7528
- fontWeight: '500',
7529
- fontSize: '14px',
7530
- cursor: 'pointer',
7531
- transition: 'all 0.15s ease',
7532
- fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
7533
- boxShadow: '0 4px 14px 0 rgba(51, 150, 255, 0.39)',
7534
- }};
7535
7521
  const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet Now', getExplorerUrl, }) => {
7536
7522
  // Always fetch balance automatically when wallet is connected
7537
7523
  // Balance is always fetched automatically from the chain
@@ -7826,7 +7812,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
7826
7812
  }, 4000); // force-resolve after 4s
7827
7813
  return () => clearTimeout(timeout);
7828
7814
  }, [isInitializing, balanceLoading, isConnecting]);
7829
- // Check chain ID and validate network
7815
+ // Remove network restriction: allow all EVM networks to connect
7830
7816
  React.useEffect(() => {
7831
7817
  const checkChain = async () => {
7832
7818
  if (!account || account.chainType !== 'evm') {
@@ -7837,16 +7823,13 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
7837
7823
  try {
7838
7824
  const chainId = await connector.getCurrentChain();
7839
7825
  setCurrentChainId(chainId);
7840
- // BSC Mainnet = 56, BSC Testnet = 97
7841
- const isBSC = chainId === 56 || chainId === 97;
7842
- setIsWrongNetwork(!isBSC && chainId !== null);
7826
+ // No restriction: allow all EVM networks
7827
+ setIsWrongNetwork(false);
7843
7828
  }
7844
7829
  catch (err) {
7845
7830
  }
7846
7831
  };
7847
7832
  checkChain();
7848
- // Also periodically check if still connected to EVM wallet
7849
- // This handles cases where chain is changed from wallet UI
7850
7833
  if (account && account.chainType === 'evm') {
7851
7834
  const interval = setInterval(checkChain, 2000);
7852
7835
  return () => clearInterval(interval);
@@ -8397,7 +8380,13 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8397
8380
  }
8398
8381
  }, [account]);
8399
8382
  const fetchTWCBalanceWithRetry = React.useCallback(async (maxRetries = 3, initialDelay = 200) => {
8383
+ // Only fetch TWC balance if wallet is on BSC (chainId 56)
8400
8384
  try {
8385
+ const state = connector.getState();
8386
+ if (state.account?.chainType !== 'evm' || state.chainId !== 56) {
8387
+ // Not on BSC, do not fetch TWC balance
8388
+ return null;
8389
+ }
8401
8390
  const twcBalance = await connector.getTWCBalance();
8402
8391
  return {
8403
8392
  balance: twcBalance.amount || '0',
@@ -8419,14 +8408,14 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8419
8408
  }
8420
8409
  return null;
8421
8410
  }, [connector]);
8422
- // Load balance when account changes
8411
+ // Load balance when account or network (chain) changes
8423
8412
  React.useEffect(() => {
8424
8413
  let isActive = true;
8425
8414
  // Only log and run effect if account is not null
8426
8415
  if (account) {
8427
- console.log('[ConnectButton] useEffect: account changed', { account });
8428
- // For EVM wallets, try to get TWC balance
8429
- if (account.chainType === 'evm') {
8416
+ console.log('[ConnectButton] useEffect: account or chain changed', { account, currentChainId });
8417
+ // For EVM wallets, only fetch TWC balance if on BSC
8418
+ if (account.chainType === 'evm' && currentChainId === 56) {
8430
8419
  // First check state/cache for immediate display
8431
8420
  const state = connector.getState();
8432
8421
  let hasBalance = false;
@@ -8449,9 +8438,9 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8449
8438
  hasBalance = true;
8450
8439
  }
8451
8440
  }
8452
- // Only fetch if we don't have a balance yet
8453
- if (!hasBalance) {
8454
- console.log('[ConnectButton] Fetching TWC balance for EVM wallet:', account.address);
8441
+ // Only fetch if we don't have a balance yet, or if the chain/network changed
8442
+ if (!hasBalance || currentChainId !== null) {
8443
+ console.log('[ConnectButton] Fetching TWC balance for BSC wallet:', account.address, currentChainId);
8455
8444
  fetchTWCBalanceWithRetry(2, 200).then((result) => {
8456
8445
  if (!isActive)
8457
8446
  return;
@@ -8469,16 +8458,23 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8469
8458
  setTwcBalance('0');
8470
8459
  setUsdValueStable(null);
8471
8460
  setIsInitializing(false);
8472
- console.warn('[ConnectButton] No TWC balance found for EVM wallet:', account.address);
8461
+ console.warn('[ConnectButton] No TWC balance found for BSC wallet:', account.address);
8473
8462
  }
8474
8463
  }).catch(() => {
8475
8464
  if (!isActive)
8476
8465
  return;
8477
8466
  setIsInitializing(false);
8478
- console.error('[ConnectButton] Error fetching TWC balance for EVM wallet:', account.address);
8467
+ console.error('[ConnectButton] Error fetching TWC balance for BSC wallet:', account.address);
8479
8468
  });
8480
8469
  }
8481
8470
  }
8471
+ else if (account.chainType === 'evm' && currentChainId !== 56) {
8472
+ // EVM wallet but not on BSC, do not fetch TWC balance, do not show switch chain
8473
+ setTwcBalance(null);
8474
+ setUsdValueStable(null);
8475
+ setIsInitializing(false);
8476
+ // Do not show error or prompt
8477
+ }
8482
8478
  else {
8483
8479
  // Non-EVM wallet, just check state
8484
8480
  const state = connector.getState();
@@ -8499,7 +8495,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8499
8495
  isActive = false;
8500
8496
  };
8501
8497
  // eslint-disable-next-line react-hooks/exhaustive-deps
8502
- }, [account?.address]);
8498
+ }, [account?.address, currentChainId]);
8503
8499
  // Polling mechanism as fallback to ensure TWC balance is always fetched
8504
8500
  React.useEffect(() => {
8505
8501
  if (!account || account.chainType !== 'evm') {
@@ -8666,7 +8662,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8666
8662
  alert('Address copied to clipboard!');
8667
8663
  }
8668
8664
  }, [account]);
8669
- const handleSwitchToBSC = React.useCallback(async () => {
8665
+ React.useCallback(async () => {
8670
8666
  try {
8671
8667
  // Try to switch to BSC Mainnet (56)
8672
8668
  await connector.switchChain(56);
@@ -8691,85 +8687,47 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
8691
8687
  }, [connector, account]);
8692
8688
  // Render button based on connection status
8693
8689
  const renderButton = () => {
8694
- // Check if we're waiting for connection OR waiting for balance to load
8695
- // Show loading if: initializing, connecting, OR (account exists but balance hasn't loaded/resolved yet)
8696
- // For TON: treat as resolved after fetch completes (even if 0). For others: treat zero/empty as resolved.
8697
- (balance.amount && balance.amount !== '0' && balance.amount !== '0.00' && balance.amount !== '' && balance.amount !== 'Loading...') ||
8698
- (twcBalance && twcBalance !== '0' && twcBalance !== '0.00' && twcBalance !== '' && twcBalance !== 'Loading...');
8699
- // Treat balance loading as background; only gate on initial connection.
8700
- const isCheckingConnection = isInitializing || ((status === exports.ConnectionStatus.CONNECTING || isConnecting) && !account);
8701
- const isActuallyConnecting = (status === exports.ConnectionStatus.CONNECTING || isConnecting) && !!account && !isInitializing;
8702
- // Check connection state
8703
- if (isCheckingConnection) {
8704
- // Show loading connected button structure while checking connection
8705
- const isMobile = isMobileViewport();
8706
- // Loading spinner component
8707
- const LoadingSpinner = () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { style: {
8708
- width: isMobile ? '12px' : '14px',
8709
- height: isMobile ? '12px' : '14px',
8710
- border: '2px solid rgba(255, 255, 255, 0.3)',
8711
- borderTopColor: '#FFFFFF',
8712
- borderRadius: '50%',
8713
- animation: 'spin 0.8s linear infinite',
8714
- } }), jsxRuntime.jsx("style", { children: `
8715
- @keyframes spin {
8716
- to { transform: rotate(360deg); }
8717
- }
8718
- ` })] }));
8719
- return (jsxRuntime.jsx("button", { onClick: () => setShowDetailsModal(false), style: {
8690
+ // Only show connect button if we are fully initialized and truly disconnected
8691
+ if (!isInitializing && (!account || status === exports.ConnectionStatus.DISCONNECTED)) {
8692
+ // Wallet icon SVG component
8693
+ 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" })] }));
8694
+ return (jsxRuntime.jsxs("button", { onClick: () => handleOpenModal(), style: {
8720
8695
  display: 'flex',
8721
8696
  alignItems: 'center',
8722
- justifyContent: 'space-between',
8723
- padding: isMobile ? '4px 4px' : '6px 6px',
8724
- borderRadius: '50px',
8697
+ gap: '10px',
8698
+ padding: '12px 12px',
8699
+ borderRadius: '12px',
8725
8700
  border: 'none',
8726
- background: '#2A2A2A',
8727
- minWidth: isMobile ? '160px' : '320px',
8728
- maxWidth: isMobile ? '100%' : undefined,
8729
- cursor: 'default',
8701
+ backgroundColor: '#FF9814',
8702
+ color: '#000000',
8703
+ fontWeight: '700',
8704
+ fontSize: '15px',
8705
+ cursor: 'pointer',
8706
+ transition: 'all 0.15s ease',
8730
8707
  fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8708
+ boxShadow: '0 2px 8px rgba(255, 152, 20, 0.3)',
8731
8709
  ...style,
8732
- }, className: className, disabled: true, children: jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: isMobile ? '6px' : '10px', flex: '1', minWidth: 0, padding: isMobile ? '4px' : '8px' }, children: [twcIconMemoized, jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: isMobile ? '4px' : '6px', minWidth: 0 }, children: [jsxRuntime.jsx(LoadingSpinner, {}), jsxRuntime.jsx("div", { style: {
8733
- fontSize: isMobile ? '11px' : '12px',
8734
- fontWeight: '400',
8735
- color: '#FFFFFF',
8736
- fontFamily: 'Lexend, sans-serif',
8737
- }, children: "Loading..." }), jsxRuntime.jsx("div", { style: {
8738
- fontSize: isMobile ? '11px' : '12px',
8739
- fontWeight: '400',
8740
- color: '#FFFFFF',
8741
- fontFamily: 'Lexend, sans-serif',
8742
- flexShrink: 0,
8743
- }, children: "TWC" })] })] }) }));
8710
+ }, className: className, onMouseEnter: (e) => {
8711
+ e.currentTarget.style.backgroundColor = '#E8870F';
8712
+ e.currentTarget.style.transform = 'translateY(-1px)';
8713
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(255, 152, 20, 0.4)';
8714
+ }, onMouseLeave: (e) => {
8715
+ e.currentTarget.style.backgroundColor = '#FF9814';
8716
+ e.currentTarget.style.transform = 'translateY(0)';
8717
+ e.currentTarget.style.boxShadow = '0 2px 8px rgba(255, 152, 20, 0.3)';
8718
+ }, 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 })] }));
8744
8719
  }
8745
- if (isActuallyConnecting) {
8746
- return (jsxRuntime.jsx("button", { style: { ...defaultStyles.button, opacity: 0.7, ...style }, className: className, disabled: true, children: "\u23F3 Connecting..." }));
8720
+ // ...existing code...
8721
+ // All other states (including loading, connecting, connected) should only show the connected button or loading spinner if account is present or initializing is true
8722
+ // If initializing, show nothing (or a spinner if desired)
8723
+ if (isInitializing) {
8724
+ // Optionally, you can show a spinner or skeleton here, but do not show connect/disconnect buttons
8725
+ return null;
8747
8726
  }
8727
+ // ...existing code...
8728
+ // The rest of the renderButton logic (wrong network, connected, etc.) remains unchanged
8748
8729
  if (account) {
8749
- // Show "Wrong Network" button if connected to non-BSC network
8750
- if (isWrongNetwork) {
8751
- return (jsxRuntime.jsx("button", { onClick: handleSwitchToBSC, style: {
8752
- padding: '10px 16px',
8753
- borderRadius: '16px',
8754
- border: 'none',
8755
- backgroundColor: '#F59E0B',
8756
- display: 'flex',
8757
- alignItems: 'center',
8758
- gap: '10px',
8759
- cursor: 'pointer',
8760
- transition: 'all 0.15s ease',
8761
- fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8762
- ...style,
8763
- }, className: className, onMouseEnter: (e) => {
8764
- e.currentTarget.style.backgroundColor = '#D97706';
8765
- e.currentTarget.style.transform = 'translateY(-1px)';
8766
- e.currentTarget.style.boxShadow = '0 4px 12px rgba(245, 158, 11, 0.4)';
8767
- }, onMouseLeave: (e) => {
8768
- e.currentTarget.style.backgroundColor = '#F59E0B';
8769
- e.currentTarget.style.transform = 'translateY(0)';
8770
- e.currentTarget.style.boxShadow = 'none';
8771
- }, children: jsxRuntime.jsx("span", { style: { fontSize: '13px', fontWeight: '600', color: 'white' }, children: "\uD83D\uDD04 Switch to BSC" }) }));
8772
- }
8730
+ // ...existing code...
8773
8731
  // Show normal connected button - styled to match design
8774
8732
  // Parse balance amount and symbol separately
8775
8733
  // For TON: show TON balance (not TWC, not NFT count in button)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiwiflix-wallet-connector",
3
- "version": "1.5.9",
3
+ "version": "1.6.0",
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",