diff --git a/assets/js/webapp/wallet.js b/assets/js/webapp/wallet.js index a69a57d..8c4a0eb 100644 --- a/assets/js/webapp/wallet.js +++ b/assets/js/webapp/wallet.js @@ -527,6 +527,54 @@ document.addEventListener('click', (e) => { } }); +// ====================== SHARE WALLET ADDRESS ====================== +function initShareWalletButton() { + const shareBtn = document.getElementById('shareWalletBtn'); + if (!shareBtn) return; + + shareBtn.addEventListener('click', async () => { + // 1. Get the dynamic address from storage + const address = localStorage.getItem('wallet_address'); + if (!address) { + alert("No wallet address found."); + return; + } + + // 2. Updated: share only the address + const shareText = address; + + // 3. Try native share + if (navigator.share) { + try { + await navigator.share({ + title: 'My Giddy Key Wallet', + text: shareText + // Removed 'url' so only the address is shared + }); + return; + } catch (err) { + console.log("Share cancelled or failed"); + } + } + + // 4. Fallback: Copy address to clipboard + try { + await navigator.clipboard.writeText(address); + + // Visual feedback + const originalIcon = shareBtn.innerHTML; + shareBtn.innerHTML = ``; + + setTimeout(() => { + shareBtn.innerHTML = originalIcon; + }, 1500); + + } catch (err) { + prompt("Copy your wallet address:", address); + } + }); +} + // ====================== STATE PROTECTION ====================== let lastFetchWallet = null; @@ -1245,6 +1293,9 @@ document.addEventListener('DOMContentLoaded', () => { } initOAuthListener(); + // ====================== SHARE WALLET BUTTON ====================== + initShareWalletButton(); // ← Add this line here + // 3. Keep cross-window communication for specific legacy needs window.addEventListener('message', async (event) => { if (event.data?.type === 'phantom-callback') { diff --git a/wallet.html b/wallet.html index 8a77434..1e42bf5 100644 --- a/wallet.html +++ b/wallet.html @@ -582,256 +582,289 @@
- -
- +
+ + + + @@ -1021,13 +1054,21 @@