Fix: buy links wallet first; achievement milestones use live buyerCount
- Buying now ensures the wallet is LINKED to the account before the purchase (one signature if not linked). Without it, a wallet only connected for the faucet bought successfully but credits resolved against member id 0 and never showed until a manual link. Matches the "buying links your wallet" promise. - Dashboard computed achievement milestones from buyerCount BEFORE reading it from chain (always 0), so Surge/Circuit/Nexus never unlocked even when qualification advanced. Moved the milestone block after the chain read. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1063,6 +1063,14 @@
|
||||
wrap.querySelectorAll('button[data-id]').forEach(b => b.addEventListener('click', async () => {
|
||||
try {
|
||||
b.disabled = true;
|
||||
// the buyer's credits are read by the member id of their LINKED wallet.
|
||||
// If they only connected a wallet (e.g. for the faucet) but never linked
|
||||
// it, link it first (one signature) so the purchase's credits show up.
|
||||
const meNow = await (await fetch('/api/me')).json();
|
||||
if (!meNow.address) {
|
||||
IAP.status('Link your wallet first — one quick signature…');
|
||||
await IAPWallet.signIn();
|
||||
}
|
||||
const spNow = await (await fetch('/api/sponsor')).json();
|
||||
IAP.status('Confirm the purchase in your wallet…');
|
||||
const r = await IAPWallet.buy(Number(b.dataset.id), spNow.sponsorId || 0, b.dataset.cost);
|
||||
|
||||
+4
-4
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Member area | InstantAdPay</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260907h">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260907i">
|
||||
</head>
|
||||
<body class="bo-body">
|
||||
|
||||
@@ -641,9 +641,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260907h"></script>
|
||||
<script src="/assets/common.js?v=20260907i"></script>
|
||||
<script src="/assets/wallet.js?v=20260907f"></script>
|
||||
<script src="/assets/my.js?v=20260907h"></script>
|
||||
<script src="/assets/chat.js?v=20260907h"></script>
|
||||
<script src="/assets/my.js?v=20260907i"></script>
|
||||
<script src="/assets/chat.js?v=20260907i"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user