diff --git a/public/assets/my.js b/public/assets/my.js index fec1e8a..b073a20 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -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); diff --git a/public/my.html b/public/my.html index 12caa84..a7bafe9 100644 --- a/public/my.html +++ b/public/my.html @@ -4,7 +4,7 @@ Member area | InstantAdPay - + @@ -641,9 +641,9 @@ - + - - + + diff --git a/server.js b/server.js index 23413bd..e989928 100644 --- a/server.js +++ b/server.js @@ -480,17 +480,6 @@ const server = http.createServer(async (req, res) => { online: (Date.now() - (spon.lastSeen || 0)) < 60000, available: spon.chatAvailable !== false }; } - // achievement milestones (same ladder as the Overview stepper) + one-time credit bonuses - { - const bc = out.buyerCount || 0; - const reached = []; - if (out.memberId) reached.push('payouts'); - if (bc >= 1) reached.push('firstBuyer'); - if (bc >= 2) reached.push('level2'); - if (bc >= 5) reached.push('level3'); - out.milestonesReached = reached; - if (out.email && reached.length) out.milestonesGranted = await ads.grantMilestones(out.email, reached); - } if (out.email) { // unmissable login modal when the upline sent a message const un = await messages.newestUnread(out.email); if (un) { @@ -514,6 +503,18 @@ const server = http.createServer(async (req, res) => { out.earnedWei = earned.toString(); out.earnCount = n; } + // achievement milestones (same ladder as the Overview stepper) + one-time credit + // bonuses — computed AFTER buyerCount is read from chain above (else always 0) + { + const bc = out.buyerCount || 0; + const reached = []; + if (out.memberId) reached.push('payouts'); + if (bc >= 1) reached.push('firstBuyer'); + if (bc >= 2) reached.push('level2'); + if (bc >= 5) reached.push('level3'); + out.milestonesReached = reached; + if (out.email && reached.length) out.milestonesGranted = await ads.grantMilestones(out.email, reached); + } // who joined through this member: their invite link uses username when set, // else code, and the numeric id once on-chain — match all three const refs = [];