OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet-desktop commits / c87f0a1

Fix: use current account index for token transfers and add testnet contract fallbacks
Deployment: testing (hyper-wallet-desktop-test) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c87f0a10afe9945c251f59d390cad37e2237ade6
by plankatron <fleeky@gmail.com> · 2026-01-30T03:02:44.000Z

Changed files (2) +49 -14

.claude/deployment-history.json +2 -2
……@@ -4,7 +4,7 @@
44 "branch": "testing",
55 "version": "unknown",
66 "pear_key": "pear://unknown",
7 "deployed_at": "2026-01-29T21:52:47-05:00",
8 "commit_message": "Fix: display gas fees in ETH instead of Gwei for token transfers",
7 "deployed_at": "2026-01-29T21:57:08-05:00",
8 "commit_message": "Fix: show token amount + ETH gas in Total display for token transfers",
99 "tmux": "pear-seed:5"
1010}
wallet-server.cjs +47 -12
……@@ -1756,11 +1756,28 @@ const routes = {
17561756 }
17571757 const amountBigInt = amountValidation.amount
17581758
1759 // Get current address index (not hardcoded 0)
1760 const currentAddr = await getCurrentAddress(baseChain)
1761 const accountIndex = currentAddr ? currentAddr.index : 0
1762
17591763 const { wdk } = await initializeWDK(walletMnemonic, { testnet: network === 'testnet' })
1760 const account = await wdk.getAccount(baseChain, 0)
1764 const account = await wdk.getAccount(baseChain, accountIndex)
1765
1766 // Check token balance (with testnet fallback)
1767 let tokenBalance
1768 try {
1769 tokenBalance = await account.getTokenBalance(tokenInfo.contractAddress)
1770 } catch (balanceErr) {
1771 if (network === 'testnet') {
1772 console.warn(`Token balance check failed on testnet (contract may not exist): ${balanceErr.message}`)
1773 // On testnet, skip balance check if contract doesn't exist
1774 // User is responsible for ensuring they have tokens
1775 tokenBalance = amountBigInt + BigInt(1) // Allow the transfer to proceed
1776 } else {
1777 return sendError(res, `Cannot check ${tokenInfo.symbol} balance: ${balanceErr.message}`, 400)
1778 }
1779 }
17611780
1762 // Check token balance
1763 const tokenBalance = await account.getTokenBalance(tokenInfo.contractAddress)
17641781 if (amountBigInt > tokenBalance) {
17651782 return sendError(res, `Insufficient ${tokenInfo.symbol} balance`, 400)
17661783 }
……@@ -1768,7 +1785,7 @@ const routes = {
17681785 // Check native balance for gas (ETH needed for gas fees)
17691786 const ethBalance = await account.getBalance()
17701787
1771 // Get fee estimate for token transfer
1788 // Get fee estimate for token transfer (with testnet fallback)
17721789 let fee
17731790 try {
17741791 const quote = await account.quoteTransfer({
……@@ -1777,9 +1794,18 @@ const routes = {
17771794 amount: amountBigInt
17781795 })
17791796 fee = quote.fee
1780 } catch (err) {
1781 console.error('Fee estimation failed:', err)
1782 return sendError(res, `Cannot estimate fee: ${err.message}`, 400)
1797 } catch (quoteErr) {
1798 if (network === 'testnet') {
1799 // Testnet contracts may not exist - use estimate
1800 console.warn(`Token fee estimation failed on testnet, using estimate: ${quoteErr.message}`)
1801 const provider = account.provider || (await wdk.getProvider(baseChain))
1802 const feeData = await provider.getFeeData()
1803 const gasPrice = feeData.gasPrice || BigInt(20000000000) // 20 gwei fallback
1804 fee = BigInt(65000) * gasPrice // ERC-20 transfer ~65k gas
1805 } else {
1806 console.error('Fee estimation failed:', quoteErr)
1807 return sendError(res, `Cannot estimate fee: ${quoteErr.message}`, 400)
1808 }
17831809 }
17841810
17851811 // Check sufficient ETH for gas
……@@ -1788,11 +1814,20 @@ const routes = {
17881814 }
17891815
17901816 // Transfer token
1791 const result = await account.transfer({
1792 token: tokenInfo.contractAddress,
1793 recipient: to,
1794 amount: amountBigInt
1795 })
1817 let result
1818 try {
1819 result = await account.transfer({
1820 token: tokenInfo.contractAddress,
1821 recipient: to,
1822 amount: amountBigInt
1823 })
1824 } catch (transferErr) {
1825 console.error('Token transfer failed:', transferErr)
1826 if (network === 'testnet') {
1827 return sendError(res, `Testnet ${tokenInfo.symbol} transfer failed - the testnet token contract may not exist. Error: ${transferErr.message}`, 400)
1828 }
1829 return sendError(res, `Token transfer failed: ${transferErr.message}`, 500)
1830 }
17961831
17971832 console.log(`✅ Token transfer sent: ${result.hash}`)
17981833 console.log(` Token: ${tokenInfo.symbol}`)