Buy flow: balance pre-flight; Trust Wallet users get a drain-warning heads-up

Stops early when the wallet lacks the POL. Only Trust Wallet users see the
proportion warning (smaller package / add POL / other wallet); everyone else
goes straight to the wallet confirmation. Buy-pane tip + chatbot reworded.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-09 07:23:19 -05:00
parent 68d68b1ebf
commit 9608d07544
5 changed files with 33 additions and 4 deletions
+8 -1
View File
@@ -221,5 +221,12 @@ window.IAPWallet = (function () {
try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|wagmi|appkit/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
}
return { connect, signIn, buy, activate, waitTx, disconnect };
// native balance of the connected wallet (pre-flight check before a buy)
async function balance(addr) {
await connect();
const h = await eth().request({ method: 'eth_getBalance', params: [addr || currentAddress(), 'latest'] });
return BigInt(h);
}
function walletName() { try { const w = modal && modal.getWalletInfo && modal.getWalletInfo(); return (w && w.name) || ''; } catch (e) { return ''; } }
return { connect, signIn, buy, activate, waitTx, disconnect, balance, address: currentAddress, walletName };
})();