OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet-desktop commits / 378b549

Fix: add fallback for testnet token fee estimation when contract unavailable
Deployment: testing (hyper-wallet-desktop-test) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
378b549a3cfa3489a3bf7827a5a28cb7a520636e
by plankatron <fleeky@gmail.com> · 2026-01-30T02:33:54.000Z

Changed files (2) +35 -12

.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:25:34-05:00",
8 "commit_message": "Fix: prevent address selector cascade, preserve unified view on address change",
7 "deployed_at": "2026-01-29T21:31:04-05:00",
8 "commit_message": "Fix: use dataset flag to prevent address selector cascade, remove reload from onchange",
99 "tmux": "pear-seed:5"
1010}
wallet-server.cjs +33 -10
……@@ -1628,21 +1628,44 @@ const routes = {
16281628 const { wdk } = await initializeWDK(walletMnemonic, { testnet: network === 'testnet' })
16291629 const account = await wdk.getAccount(baseChain, 0)
16301630
1631 // Quote token transfer (fee in ETH, not USDT)
1632 const quote = await account.quoteTransfer({
1633 token: tokenInfo.contractAddress,
1634 recipient: to,
1635 amount: amountBigInt
1636 })
1631 let fee
1632 try {
1633 // Quote token transfer (fee in ETH, not USDT)
1634 const quote = await account.quoteTransfer({
1635 token: tokenInfo.contractAddress,
1636 recipient: to,
1637 amount: amountBigInt
1638 })
1639 fee = quote.fee
1640 } catch (quoteErr) {
1641 // On testnet, the token contract may not exist or be valid
1642 // Fall back to estimated gas: ~65000 gas for ERC-20 transfer
1643 if (network === 'testnet') {
1644 console.warn(`Token fee estimation failed on testnet, using estimate: ${quoteErr.message}`)
1645 // Get current gas price and estimate fee (65000 gas * gasPrice)
1646 try {
1647 const provider = account.provider || wdk.provider
1648 const feeData = await provider.getFeeData()
1649 const gasPrice = feeData.gasPrice || BigInt(20000000000) // 20 gwei fallback
1650 fee = BigInt(65000) * gasPrice
1651 } catch (priceErr) {
1652 // Complete fallback: assume 20 gwei gas price
1653 fee = BigInt(65000) * BigInt(20000000000) // ~0.0013 ETH
1654 }
1655 } else {
1656 throw quoteErr // Re-throw on mainnet - need accurate fee
1657 }
1658 }
16371659
16381660 sendJSON(res, {
1639 fee: quote.fee.toString(),
1661 fee: fee.toString(),
16401662 total: amountBigInt.toString(), // For tokens, total = amount (fee is separate in ETH)
16411663 formatted: {
1642 fee: formatAmount(quote.fee, baseChain), // Fee in ETH
1664 fee: formatAmount(fee, baseChain), // Fee in ETH
16431665 amount: `${Number(amountBigInt) / Math.pow(10, tokenInfo.decimals)} ${tokenInfo.symbol}`,
1644 total: `${Number(amountBigInt) / Math.pow(10, tokenInfo.decimals)} ${tokenInfo.symbol} + ${formatAmount(quote.fee, baseChain)} gas`
1645 }
1666 total: `${Number(amountBigInt) / Math.pow(10, tokenInfo.decimals)} ${tokenInfo.symbol} + ${formatAmount(fee, baseChain)} gas`
1667 },
1668 estimated: network === 'testnet' // Flag if this is an estimate
16461669 })
16471670 } else {
16481671 // Native token fee estimation (existing code)