tiwiflix-wallet-connector 1.6.5 → 1.6.6
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 +41 -6
- package/dist/index.js +41 -6
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7517,6 +7517,41 @@ const TWCBalanceModal = ({ isOpen, onClose, twcBalance, usdValue, colors, isDark
|
|
|
7517
7517
|
}, children: "Learn More" })] })] }) }));
|
|
7518
7518
|
};
|
|
7519
7519
|
|
|
7520
|
+
// Debug log overlay for mobile
|
|
7521
|
+
function showDebugLog(msg) {
|
|
7522
|
+
if (typeof window === 'undefined')
|
|
7523
|
+
return;
|
|
7524
|
+
let logDiv = document.getElementById('twc-debug-log');
|
|
7525
|
+
if (!logDiv) {
|
|
7526
|
+
logDiv = document.createElement('div');
|
|
7527
|
+
logDiv.id = 'twc-debug-log';
|
|
7528
|
+
logDiv.style.position = 'fixed';
|
|
7529
|
+
logDiv.style.bottom = '10px';
|
|
7530
|
+
logDiv.style.left = '10px';
|
|
7531
|
+
logDiv.style.right = '10px';
|
|
7532
|
+
logDiv.style.maxHeight = '40vh';
|
|
7533
|
+
logDiv.style.overflowY = 'auto';
|
|
7534
|
+
logDiv.style.background = 'rgba(0,0,0,0.85)';
|
|
7535
|
+
logDiv.style.color = '#fff';
|
|
7536
|
+
logDiv.style.fontSize = '12px';
|
|
7537
|
+
logDiv.style.zIndex = '99999';
|
|
7538
|
+
logDiv.style.padding = '8px 12px';
|
|
7539
|
+
logDiv.style.borderRadius = '8px';
|
|
7540
|
+
logDiv.style.pointerEvents = 'auto';
|
|
7541
|
+
logDiv.style.fontFamily = 'monospace';
|
|
7542
|
+
logDiv.style.boxShadow = '0 2px 12px rgba(0,0,0,0.3)';
|
|
7543
|
+
logDiv.innerHTML = '';
|
|
7544
|
+
document.body.appendChild(logDiv);
|
|
7545
|
+
}
|
|
7546
|
+
const now = new Date();
|
|
7547
|
+
const time = now.toLocaleTimeString();
|
|
7548
|
+
logDiv.innerHTML = `<div>[${time}] ${msg}</div>` + logDiv.innerHTML;
|
|
7549
|
+
// Limit to 30 log lines
|
|
7550
|
+
const lines = logDiv.innerHTML.split('<div>');
|
|
7551
|
+
if (lines.length > 30) {
|
|
7552
|
+
logDiv.innerHTML = lines.slice(0, 30).join('<div>');
|
|
7553
|
+
}
|
|
7554
|
+
}
|
|
7520
7555
|
const tonApiCache = new Map();
|
|
7521
7556
|
const CACHE_DURATION = 30000; // 30 seconds
|
|
7522
7557
|
const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet', getExplorerUrl, }) => {
|
|
@@ -8430,6 +8465,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8430
8465
|
// Fetch TWC balance immediately after connection
|
|
8431
8466
|
const cacheKey = `tiwiflix_twc_balance_cache_${account.address}`;
|
|
8432
8467
|
fetchTWCBalanceWithRetry(2, 200).then((result) => {
|
|
8468
|
+
showDebugLog(`[ConnectButton] TWC balance fetch after WalletConnect connect: status=${status}, account=${account?.address}, chainId=${chainId}, result=${JSON.stringify(result)}`);
|
|
8433
8469
|
if (result && result.balance !== '0' && result.balance !== '0.00') {
|
|
8434
8470
|
setTwcBalance(result.balance);
|
|
8435
8471
|
setUsdValueStable(result.usdValue);
|
|
@@ -8437,7 +8473,6 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8437
8473
|
localStorage.setItem(cacheKey, JSON.stringify({ balance: result.balance, usdValue: result.usdValue, timestamp: Date.now() }));
|
|
8438
8474
|
}
|
|
8439
8475
|
setIsInitializing(false);
|
|
8440
|
-
console.log('[ConnectButton] TWC balance fetched after WalletConnect connect:', result);
|
|
8441
8476
|
}
|
|
8442
8477
|
});
|
|
8443
8478
|
}
|
|
@@ -8468,7 +8503,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8468
8503
|
setTwcBalance(cache.balance);
|
|
8469
8504
|
setUsdValueStable(cache.usdValue);
|
|
8470
8505
|
setIsInitializing(false);
|
|
8471
|
-
|
|
8506
|
+
showDebugLog(`[ConnectButton] Using localStorage cached TWC balance: ${JSON.stringify(cache)}`);
|
|
8472
8507
|
// Fetch in background to update cache, but don't reset UI while fetching
|
|
8473
8508
|
fetchTWCBalanceWithRetry(2, 200).then((result) => {
|
|
8474
8509
|
if (!isActive)
|
|
@@ -8481,7 +8516,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8481
8516
|
localStorage.setItem(cacheKey, JSON.stringify({ balance: result.balance, usdValue: result.usdValue, timestamp: Date.now() }));
|
|
8482
8517
|
}
|
|
8483
8518
|
setIsInitializing(false);
|
|
8484
|
-
|
|
8519
|
+
showDebugLog(`[ConnectButton] TWC balance updated after background fetch: ${JSON.stringify(result)}`);
|
|
8485
8520
|
}
|
|
8486
8521
|
}).catch(() => {
|
|
8487
8522
|
// Ignore errors in background fetch
|
|
@@ -8501,19 +8536,19 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8501
8536
|
localStorage.setItem(cacheKey, JSON.stringify({ balance: result.balance, usdValue: result.usdValue, timestamp: Date.now() }));
|
|
8502
8537
|
}
|
|
8503
8538
|
setIsInitializing(false);
|
|
8504
|
-
|
|
8539
|
+
showDebugLog(`[ConnectButton] TWC balance fetched and cached: ${JSON.stringify(result)}`);
|
|
8505
8540
|
}
|
|
8506
8541
|
else {
|
|
8507
8542
|
setTwcBalance('0');
|
|
8508
8543
|
setUsdValueStable(null);
|
|
8509
8544
|
setIsInitializing(false);
|
|
8510
|
-
|
|
8545
|
+
showDebugLog(`[ConnectButton] No TWC balance found for BSC wallet: ${account.address}`);
|
|
8511
8546
|
}
|
|
8512
8547
|
}).catch(() => {
|
|
8513
8548
|
if (!isActive)
|
|
8514
8549
|
return;
|
|
8515
8550
|
setIsInitializing(false);
|
|
8516
|
-
|
|
8551
|
+
showDebugLog(`[ConnectButton] Error fetching TWC balance for BSC wallet: ${account.address}`);
|
|
8517
8552
|
});
|
|
8518
8553
|
}
|
|
8519
8554
|
}
|
package/dist/index.js
CHANGED
|
@@ -7519,6 +7519,41 @@ const TWCBalanceModal = ({ isOpen, onClose, twcBalance, usdValue, colors, isDark
|
|
|
7519
7519
|
}, children: "Learn More" })] })] }) }));
|
|
7520
7520
|
};
|
|
7521
7521
|
|
|
7522
|
+
// Debug log overlay for mobile
|
|
7523
|
+
function showDebugLog(msg) {
|
|
7524
|
+
if (typeof window === 'undefined')
|
|
7525
|
+
return;
|
|
7526
|
+
let logDiv = document.getElementById('twc-debug-log');
|
|
7527
|
+
if (!logDiv) {
|
|
7528
|
+
logDiv = document.createElement('div');
|
|
7529
|
+
logDiv.id = 'twc-debug-log';
|
|
7530
|
+
logDiv.style.position = 'fixed';
|
|
7531
|
+
logDiv.style.bottom = '10px';
|
|
7532
|
+
logDiv.style.left = '10px';
|
|
7533
|
+
logDiv.style.right = '10px';
|
|
7534
|
+
logDiv.style.maxHeight = '40vh';
|
|
7535
|
+
logDiv.style.overflowY = 'auto';
|
|
7536
|
+
logDiv.style.background = 'rgba(0,0,0,0.85)';
|
|
7537
|
+
logDiv.style.color = '#fff';
|
|
7538
|
+
logDiv.style.fontSize = '12px';
|
|
7539
|
+
logDiv.style.zIndex = '99999';
|
|
7540
|
+
logDiv.style.padding = '8px 12px';
|
|
7541
|
+
logDiv.style.borderRadius = '8px';
|
|
7542
|
+
logDiv.style.pointerEvents = 'auto';
|
|
7543
|
+
logDiv.style.fontFamily = 'monospace';
|
|
7544
|
+
logDiv.style.boxShadow = '0 2px 12px rgba(0,0,0,0.3)';
|
|
7545
|
+
logDiv.innerHTML = '';
|
|
7546
|
+
document.body.appendChild(logDiv);
|
|
7547
|
+
}
|
|
7548
|
+
const now = new Date();
|
|
7549
|
+
const time = now.toLocaleTimeString();
|
|
7550
|
+
logDiv.innerHTML = `<div>[${time}] ${msg}</div>` + logDiv.innerHTML;
|
|
7551
|
+
// Limit to 30 log lines
|
|
7552
|
+
const lines = logDiv.innerHTML.split('<div>');
|
|
7553
|
+
if (lines.length > 30) {
|
|
7554
|
+
logDiv.innerHTML = lines.slice(0, 30).join('<div>');
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7522
7557
|
const tonApiCache = new Map();
|
|
7523
7558
|
const CACHE_DURATION = 30000; // 30 seconds
|
|
7524
7559
|
const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className, style, showBalance = false, modalPosition = 'center', theme = 'auto', buttonText = 'Connect Wallet', getExplorerUrl, }) => {
|
|
@@ -8432,6 +8467,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8432
8467
|
// Fetch TWC balance immediately after connection
|
|
8433
8468
|
const cacheKey = `tiwiflix_twc_balance_cache_${account.address}`;
|
|
8434
8469
|
fetchTWCBalanceWithRetry(2, 200).then((result) => {
|
|
8470
|
+
showDebugLog(`[ConnectButton] TWC balance fetch after WalletConnect connect: status=${status}, account=${account?.address}, chainId=${chainId}, result=${JSON.stringify(result)}`);
|
|
8435
8471
|
if (result && result.balance !== '0' && result.balance !== '0.00') {
|
|
8436
8472
|
setTwcBalance(result.balance);
|
|
8437
8473
|
setUsdValueStable(result.usdValue);
|
|
@@ -8439,7 +8475,6 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8439
8475
|
localStorage.setItem(cacheKey, JSON.stringify({ balance: result.balance, usdValue: result.usdValue, timestamp: Date.now() }));
|
|
8440
8476
|
}
|
|
8441
8477
|
setIsInitializing(false);
|
|
8442
|
-
console.log('[ConnectButton] TWC balance fetched after WalletConnect connect:', result);
|
|
8443
8478
|
}
|
|
8444
8479
|
});
|
|
8445
8480
|
}
|
|
@@ -8470,7 +8505,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8470
8505
|
setTwcBalance(cache.balance);
|
|
8471
8506
|
setUsdValueStable(cache.usdValue);
|
|
8472
8507
|
setIsInitializing(false);
|
|
8473
|
-
|
|
8508
|
+
showDebugLog(`[ConnectButton] Using localStorage cached TWC balance: ${JSON.stringify(cache)}`);
|
|
8474
8509
|
// Fetch in background to update cache, but don't reset UI while fetching
|
|
8475
8510
|
fetchTWCBalanceWithRetry(2, 200).then((result) => {
|
|
8476
8511
|
if (!isActive)
|
|
@@ -8483,7 +8518,7 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8483
8518
|
localStorage.setItem(cacheKey, JSON.stringify({ balance: result.balance, usdValue: result.usdValue, timestamp: Date.now() }));
|
|
8484
8519
|
}
|
|
8485
8520
|
setIsInitializing(false);
|
|
8486
|
-
|
|
8521
|
+
showDebugLog(`[ConnectButton] TWC balance updated after background fetch: ${JSON.stringify(result)}`);
|
|
8487
8522
|
}
|
|
8488
8523
|
}).catch(() => {
|
|
8489
8524
|
// Ignore errors in background fetch
|
|
@@ -8503,19 +8538,19 @@ const ConnectButton = ({ connector, onConnect, onDisconnect, onError, className,
|
|
|
8503
8538
|
localStorage.setItem(cacheKey, JSON.stringify({ balance: result.balance, usdValue: result.usdValue, timestamp: Date.now() }));
|
|
8504
8539
|
}
|
|
8505
8540
|
setIsInitializing(false);
|
|
8506
|
-
|
|
8541
|
+
showDebugLog(`[ConnectButton] TWC balance fetched and cached: ${JSON.stringify(result)}`);
|
|
8507
8542
|
}
|
|
8508
8543
|
else {
|
|
8509
8544
|
setTwcBalance('0');
|
|
8510
8545
|
setUsdValueStable(null);
|
|
8511
8546
|
setIsInitializing(false);
|
|
8512
|
-
|
|
8547
|
+
showDebugLog(`[ConnectButton] No TWC balance found for BSC wallet: ${account.address}`);
|
|
8513
8548
|
}
|
|
8514
8549
|
}).catch(() => {
|
|
8515
8550
|
if (!isActive)
|
|
8516
8551
|
return;
|
|
8517
8552
|
setIsInitializing(false);
|
|
8518
|
-
|
|
8553
|
+
showDebugLog(`[ConnectButton] Error fetching TWC balance for BSC wallet: ${account.address}`);
|
|
8519
8554
|
});
|
|
8520
8555
|
}
|
|
8521
8556
|
}
|
package/package.json
CHANGED