Holding tank on LinkSpin (ported from InstantAdPay 4645d56, Marty 2026-10-27): network sponsor ALIGNMENT first, the free activation held (never a purchase), 24-hour rotation, payouts switched on the moment someone is assigned
- Align first, every path (/api/me, /api/sponsor all intents incl. buy, carry.ensureOnChain via tank.gate, 15-min readyTick): a tank member (no sponsorRef, no member number, no resolvable cookie) whose email has a sponsor in the InstantAdPay registry rows, else a signed sponsor-facts call (3 s timeout, 10 min cache, one batch per tick), else the same wallet, is placed under that sponsor through accounts.setSponsorRef when the sponsor has a LinkSpin account; never a sponsor they were adopted/released/rescued away from, never a loop. Recorded in tank-ready.json, listed in Admin tank - Hold ONLY the plain Switch on payouts (Marty: "I would never want to hold up a purchase ... they'll just pay number one"): the engine's wallet-link activation and seeding wait, /api/sponsor?intent=activate answers sponsorBlocked tankHold; intent=buy and /api/me never block (buys go ahead under #1 as before). A sponsor activated because someone below is buying is never held. Activate buttons now call intent=activate - Ready badge + hours left (My line tank, Admin tank, Overview count); one shared-payments-topic line per newly ready member (digest when more than 3) - 24-hour rotation through adopt(): own $25+ buy, fewer than 2 open, seen within 7 days, not company/#1, not a no-payout chain, not own downline; least recently auto-assigned first. Nobody eligible: keep holding, one admin alert. Never #1 - Payouts on at assignment (Marty approved 2026-10-27): adopted, auto-assigned or aligned member with a wallet is activated right away by carry.activateAssigned (strict: sponsor must be on the contract and not on a no-payout chain, never the fallback; retried every tick for 7 days); the auto-assign chat/email say "Your payouts are now on under @sponsor" with the Polygonscan link, a manual adoption gets a follow-up chat + email - Deploy overlap: marks.js claims for the activation (per member per 10 min), the auto-assign, the ready post and the admin alert - Cross-site: someone waiting in InstantAdPay's own tank (claimed account there, no sponsor, not a member there, wallet linked) is auto-assigned by InstantAdPay only (live sponsor-facts, registry fallback); LinkSpin defers and does not post them - Chatbot: tank-hold canned answer, holding-tank answer + facts, KNOWLEDGE_DATE 2026-10-27; cache tags my.js / credits-screen.js / admin.js 20261027th - QA: qa/tank-hold.test.mjs (unit with mocked clock + fake engine, then a local copy with a mock InstantAdPay and a browser check of Credits), qa/carry-activate.test.cjs (regression for the 10-22 scoping bug), run.sh tankhold + sponsorfollow; run.sh borrows InstantAdPay's node_modules when this checkout has none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -535,6 +535,6 @@
|
||||
|
||||
<script src="/assets/common.js?v=20261023ov"></script>
|
||||
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
||||
<script src="/assets/admin.js?v=20261023ov"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
|
||||
<script src="/assets/admin.js?v=20261027th"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -296,8 +296,13 @@
|
||||
async function loadTank() {
|
||||
try {
|
||||
const r = await (await fetch('/api/admin/tank')).json(); if (r.error) return;
|
||||
$('tankAdmSub').textContent = r.waiting.length + ' waiting · cap ' + r.cap + ' open per adopter · ' + r.ttlDays + '-day window';
|
||||
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th></tr>' + (r.waiting.length ? r.waiting.map(w => '<tr><td>' + esc(w.name) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">empty</td></tr>');
|
||||
const nReady = r.waiting.filter(w => w.ready).length;
|
||||
$('tankAdmSub').textContent = r.waiting.length + ' waiting' + (nReady ? ' (' + nReady + ' ready to activate)' : '') + ' · cap ' + r.cap + ' open per adopter · ' + r.ttlDays + '-day window · ready members: the free activation is held ' + (r.holdHours || 24) + ' h (a purchase never is), then auto-assigned in rotation';
|
||||
// ready = wallet linked: the plain activation is held (never the company) until someone adopts them or the 24-hour safety net assigns them (2026-10-27)
|
||||
const left = w => { const ms = (w.holdUntil || 0) - Date.now(); if (ms <= 0) return 'assigning now'; const m = Math.round(ms / 60000); return (m >= 60 ? Math.floor(m / 60) + ' h ' + (m % 60) + ' min' : m + ' min') + ' left'; };
|
||||
const rb = w => w.ready ? ' <span class="badge" style="background:rgba(34,197,94,.15);border-color:#22c55e;color:#22c55e">Ready to activate · ' + left(w) + '</span>' : '';
|
||||
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th></tr>' + (r.waiting.length ? r.waiting.map(w => '<tr><td>' + esc(w.name) + rb(w) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">empty</td></tr>')
|
||||
+ ((r.aligned || []).length ? '<tr><th colspan="4">Aligned to their network sponsor (InstantAdPay) instead of the tank</th></tr>' + r.aligned.slice(0, 15).map(x => '<tr><td>' + esc(x.email) + '</td><td>' + esc(x.toName || x.to) + '</td><td class="when">' + when(x.at) + '</td><td class="muted">' + esc(x.via || '') + '</td></tr>').join('') : '');
|
||||
$('tankAdopt').innerHTML = '<tr><th>Member</th><th>Adopted by</th><th>When</th><th>Window ends</th><th>Status</th></tr>' + (r.adoptions.length ? r.adoptions.map(a => '<tr><td>' + esc(a.adopteeName) + '</td><td>' + esc(a.adopterName) + '</td><td class="when">' + when(a.ts) + '</td><td class="when">' + (a.status === 'released' ? '' : when(a.expires)) + '</td><td>' + esc(a.status) + '</td></tr>').join('') : '<tr><td colspan="5" class="muted">none yet</td></tr>');
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
$('walletBox').innerHTML = addr
|
||||
? '<div class="code" style="display:block">' + esc(addr) + '</div>'
|
||||
+ (on ? '<div class="ok"><span class="dot"></span>Payouts on. Every package your people buy pays this wallet in the same transaction.</div>'
|
||||
: ME.tankHold ? '<div class="ink2" id="tankHoldNote" style="font-size:13px;color:#22c55e">' + esc(tankHoldText(ME.tankHold)) + '</div>' // held for an adopter: no activate button
|
||||
: '<div class="ink2" style="font-size:13px">Linked, but payouts are off until this wallet is on the contract. Buying a package does that. So does the free activation below (gas only).</div><div class="acts"><button class="btn blue" type="button" id="activateBtn">Switch on payouts (free)</button></div>')
|
||||
+ '<div class="acts"><a class="btn sm" href="' + esc((CFG && CFG.explorer) || 'https://polygonscan.com') + '/address/' + esc(addr) + '" target="_blank" rel="noopener">Open on the explorer</a><button class="btn sm" type="button" id="switchBtn">Switch account</button><button class="btn sm" type="button" id="dropBtn">Disconnect</button></div>'
|
||||
+ posBlock()
|
||||
@@ -145,8 +146,17 @@
|
||||
}
|
||||
async function guard(btn, fn) { if (btn.disabled) return; btn.disabled = true; try { await fn(); } catch (e) { CR.toast((e && e.message) || 'Something went wrong.', true); } finally { btn.disabled = false; } }
|
||||
|
||||
// holding tank (2026-10-27): no sponsor yet, so the free Switch on payouts waits for an adopter (24 hours at most).
|
||||
// A purchase is never held: buying goes ahead as before.
|
||||
const holdLeft = ms => { const m = Math.max(1, Math.round(ms / 60000)); const h = Math.floor(m / 60); return h ? h + ' h ' + (m % 60) + ' min' : m + ' min'; };
|
||||
function tankHoldText(h) {
|
||||
let t = "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours).";
|
||||
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
|
||||
return t;
|
||||
}
|
||||
// a named sponsor that cannot be paid right now: hold the transaction and say why (never credit the company by default)
|
||||
function holdText(sp) {
|
||||
if (sp.sponsorBlocked === 'tankHold') return tankHoldText(sp.tankHold); // the free activation only (intent=activate), never a buy
|
||||
const who = sp.sponsorName ? ('@' + String(sp.sponsorName).replace(/^@/, '')) : 'your sponsor';
|
||||
if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. ') + 'Your first purchase waits until ' + (sp.claim.deadline ? new Date(sp.claim.deadline).toLocaleDateString() : 'they do') + ', then it goes ahead with the nearest member above who has one. Nothing was charged.';
|
||||
if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts first (one free transaction).';
|
||||
@@ -155,7 +165,7 @@
|
||||
}
|
||||
async function linkWallet() { CR.toast('Check your wallet for the free link signature…'); await IAPWallet.signIn(); CR.toast('Wallet linked. Earnings pay there from now on.'); await load(); }
|
||||
async function activate() {
|
||||
const sp = await CR.get('/api/sponsor?intent=buy'); if (sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; return; }
|
||||
const sp = await CR.get('/api/sponsor?intent=activate'); if (sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; if (sp.sponsorBlocked === 'tankHold') { ME.tankHold = sp.tankHold || {}; paintWallet(); } return; }
|
||||
CR.toast('Confirm the free activation in your wallet…');
|
||||
const r = await IAPWallet.activate(sp.sponsorId || 0);
|
||||
if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Check the explorer.');
|
||||
|
||||
+25
-6
@@ -26,7 +26,17 @@
|
||||
return r;
|
||||
}
|
||||
|
||||
// holding tank (2026-10-27): no sponsor yet, so the free Switch on payouts waits for an adopter (24 hours at most).
|
||||
// A purchase is never held: buying goes ahead as before.
|
||||
const holdLeft = ms => { const m = Math.max(1, Math.round(ms / 60000)); const h = Math.floor(m / 60); return h ? h + ' h ' + (m % 60) + ' min' : m + ' min'; };
|
||||
function tankHoldText(h) {
|
||||
let t = "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours).";
|
||||
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
|
||||
return t;
|
||||
}
|
||||
let TANK_HOLD = null;
|
||||
function nextMove(d) {
|
||||
if (TANK_HOLD && d.address && !d.memberId) return tankHoldText(TANK_HOLD);
|
||||
if (!d.address) return 'Grab your link below and start sharing today. Then link your wallet (one free signature) so every payment can lock to you before your people start buying.';
|
||||
if (!d.memberId) return 'Your wallet is linked. Switch on payouts above (one free transaction) and every purchase in your line pays you the moment it happens.';
|
||||
if (d.buyerCount === 0) return 'Payouts are on and your link is live. Your next milestone: your first buyer of $25 or more. Every direct pays you 50 percent from their very first package.';
|
||||
@@ -498,8 +508,9 @@
|
||||
payouts: ['Switch on payouts', 'One small transaction registers your wallet with the contract so commissions can reach it. Buying any package does this automatically.', 'Activate payouts', () => jumpTo('wallet', 'activateBtn')],
|
||||
package: ['Your first package', 'From $10. The $25 package is the one that counts you as a qualifying buyer for your sponsor and unlocks adopting from the holding tank.', 'See packages', () => jumpTo('buy', null)]
|
||||
}[cur.k];
|
||||
$('gsNow').innerHTML = '<p><b>Next: ' + copy[0] + '</b>' + copy[1] + (cur.k === 'wallet' ? ' <a href="/wallets" target="_blank" rel="noopener" style="color:var(--mint)">Wallet guide</a>' : '') + '</p><button type="button" class="btn" id="gsGo">' + copy[2] + '</button>';
|
||||
$('gsGo').addEventListener('click', copy[3]);
|
||||
if (cur.k === 'payouts' && TANK_HOLD) { copy[0] = 'Matching you with a sponsor'; copy[1] = tankHoldText(TANK_HOLD); copy[2] = null; } // no activate button while held
|
||||
$('gsNow').innerHTML = '<p><b>Next: ' + copy[0] + '</b>' + copy[1] + (cur.k === 'wallet' ? ' <a href="/wallets" target="_blank" rel="noopener" style="color:var(--mint)">Wallet guide</a>' : '') + '</p>' + (copy[2] ? '<button type="button" class="btn" id="gsGo">' + copy[2] + '</button>' : '');
|
||||
if (copy[2]) $('gsGo').addEventListener('click', copy[3]);
|
||||
card.hidden = false;
|
||||
}
|
||||
function jumpTo(pane, id) {
|
||||
@@ -600,7 +611,8 @@
|
||||
tn.hidden = !(tw && tw.count);
|
||||
if (tw && tw.count) tn.innerHTML = '<b>' + tw.count + (tw.count === 1 ? ' person is' : ' people are') + ' waiting for a sponsor in the holding tank</b> \u00b7 '
|
||||
+ tw.names.map(esc).join(', ') + (tw.count > tw.names.length ? ' and more' : '') + '. <a href="#line">Adopt them from My line</a>'
|
||||
+ (tw.eligible ? '.' : ' (you need your own $25 package first).');
|
||||
+ (tw.eligible ? '.' : ' (you need your own $25 package first).')
|
||||
+ (tw.ready ? ' <b style="color:#22c55e">' + tw.ready + ' of them ' + (tw.ready === 1 ? 'has' : 'have') + ' linked a wallet and ' + (tw.ready === 1 ? 'is' : 'are') + ' ready to switch on payouts.</b>' : '');
|
||||
}
|
||||
} catch (e) {}
|
||||
if (d.username) { // wall link rides the username
|
||||
@@ -697,6 +709,7 @@
|
||||
else if (!render.waiting) { render.waiting = true; window.addEventListener('ls:session', () => { render.waiting = false; render(); }, { once: true }); }
|
||||
}
|
||||
if (!signedIn) return;
|
||||
TANK_HOLD = (!me.memberId && me.tankHold) || null;
|
||||
if ($('adminLink')) $('adminLink').hidden = !me.isAdmin; // admin portal link, only for ADMIN_EMAIL
|
||||
// REQUIRED first step (Marty, 2026-09-12): no username, nothing else. The modal cannot be
|
||||
// skipped or dismissed; it resolves only when a username is saved, then the area renders.
|
||||
@@ -726,13 +739,16 @@
|
||||
else who.push('<span style="display:inline-flex;align-items:center;gap:8px"><span aria-hidden="true" style="display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;border:2px solid var(--muted);color:var(--muted);font-weight:900;font-size:12px;line-height:1">!</span><b>No wallet connected yet</b> <span class="muted">(link one below)</span></span>');
|
||||
if (me.memberId) who.push('on-chain <b>member #' + me.memberId + '</b>'
|
||||
+ (me.onchainSponsorId ? ', sponsored by #' + me.onchainSponsorId : ''));
|
||||
else if (me.sponsorId) who.push('invited by member #' + me.sponsorId);
|
||||
else if (me.sponsorId && !TANK_HOLD) who.push('invited by member #' + me.sponsorId);
|
||||
$('posLine').innerHTML = who.join('<br>');
|
||||
|
||||
$('creditLine').textContent = (me.credits || 0).toLocaleString();
|
||||
loadPositions(me);
|
||||
$('linkCard').hidden = !!me.address;
|
||||
$('activateCard').hidden = !(me.address && !me.memberId);
|
||||
{ let hn = $('tankHoldNote'); // held for an adopter: say so, and no activate button
|
||||
if (!hn) { hn = document.createElement('p'); hn.id = 'tankHoldNote'; hn.className = 'small'; hn.style.cssText = 'margin:8px 0 0;color:#22c55e'; $('activateBtn').insertAdjacentElement('beforebegin', hn); }
|
||||
hn.hidden = !TANK_HOLD; hn.textContent = TANK_HOLD ? tankHoldText(TANK_HOLD) : ''; $('activateBtn').hidden = !!TANK_HOLD; }
|
||||
$('activityArea').hidden = !me.memberId;
|
||||
$('campGate').hidden = true; // earned credits fund campaigns for everyone
|
||||
$('campaignCard').hidden = false;
|
||||
@@ -1265,7 +1281,8 @@
|
||||
$('tankMine').querySelectorAll('[data-tchat]').forEach(b => b.addEventListener('click', () => openConvo(b.dataset.tchat, b.dataset.tname)));
|
||||
$('tankMine').querySelectorAll('[data-pif]').forEach(b => b.addEventListener('click', () => pif(b.dataset.pif, b.dataset.pname, b.dataset.paddr)));
|
||||
if (!r.waiting.length) { el.innerHTML = '<p class="muted small">The tank is empty. Anyone who joins from the public site without a sponsor lands here.</p>'; return; }
|
||||
el.innerHTML = r.waiting.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + '</span>'
|
||||
const readyBadge = w => w.ready ? ' <span class="badge" style="background:rgba(34,197,94,.15);border-color:#22c55e;color:#22c55e" title="Wallet linked. If nobody adopts them, the site assigns them to the next eligible adopter when the time runs out.">Ready to activate \u00b7 ' + (w.holdUntil > Date.now() ? holdLeft(w.holdUntil - Date.now()) + ' left' : 'assigning now') + '</span>' : '';
|
||||
el.innerHTML = r.waiting.slice().sort((a, b) => (b.ready ? 1 : 0) - (a.ready ? 1 : 0)).map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + readyBadge(w) + '</span>'
|
||||
+ '<span class="em">joined ' + ago(w.joined) + '</span>'
|
||||
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
|
||||
+ (r.eligible ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('');
|
||||
@@ -2268,10 +2285,12 @@
|
||||
if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. They have until ' + new Date(sp.claim.deadline).toLocaleString() + ' to do it, and we have told them. ') + 'You can use everything else meanwhile; your purchase waits so it pays the right person.';
|
||||
if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts (Wallet tab, one free transaction), then try again.';
|
||||
if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.';
|
||||
if (sp.sponsorBlocked === 'tankHold') return tankHoldText(sp.tankHold);
|
||||
return 'Your sponsor link could not be matched to a member. Send a ticket from Help (/help) before buying so ' + who + ' gets credit.';
|
||||
}
|
||||
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
|
||||
const me = await (await fetch('/api/sponsor?intent=buy')).json();
|
||||
const me = await (await fetch('/api/sponsor?intent=activate')).json(); // the free activation: a tank member waits for an adopter (a buy never does)
|
||||
if (me.sponsorBlocked === 'tankHold') { TANK_HOLD = me.tankHold || {}; IAP.status(tankHoldText(me.tankHold), 'ok'); await render(); return; }
|
||||
if (me.sponsorBlocked) { IAP.status(sponsorHoldText(me), 'bad'); return; }
|
||||
IAP.status('Confirm the free activation in your wallet…');
|
||||
const r = await IAPWallet.activate(me.sponsorId || 0);
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@
|
||||
<script src="/assets/common.js?v=20261023ov"></script>
|
||||
<script src="/assets/wallet.js?v=20261021a"></script>
|
||||
<script src="/assets/cr-shell.js?v=20261025ff"></script>
|
||||
<script src="/assets/credits-screen.js?v=20261026a"></script>
|
||||
<script src="/assets/credits-screen.js?v=20261027th"></script>
|
||||
<script src="/assets/fuel.js?v=20261025ff"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -1012,7 +1012,7 @@
|
||||
<script src="/assets/tools.js?v=20261011a"></script>
|
||||
<script src="/assets/wallet.js?v=20261021a"></script>
|
||||
<script src="/assets/promo.js?v=20261020bs3"></script>
|
||||
<script src="/assets/my.js?v=20261026a"></script>
|
||||
<script src="/assets/my.js?v=20261027th"></script>
|
||||
<script src="/assets/chat.js?v=20261016a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user