Never hold a purchase: the 3-day claim window is gone. A sponsor with a wallet is activated by the engine (one retry); no wallet, unknown sponsor or a failed activation walks up to the nearest ancestor with a wallet, else the company. Only the buy (intent=buy) moves the member and sends notices; /api/me and /api/sponsor block only on an RPC hiccup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,8 @@
|
||||
// position on this contract, the engine activates them on their behalf (activateFor,
|
||||
// engine-signed, gas paid by the engine), walking up until it reaches someone already
|
||||
// on-chain. The sponsor is told, and their first payout email follows on its own.
|
||||
// - Sponsor with no wallet at all: the claim window. The member can do everything except
|
||||
// buy; the sponsor has CLAIM_DAYS to link a wallet. After that the seat walks up to the
|
||||
// nearest ancestor with a wallet and both sides are told.
|
||||
// - Sponsor with no wallet at all: NO hold (the claim window was removed 2026-10-15). At the
|
||||
// buy, the seat walks up to the nearest ancestor with a wallet and both sides are told.
|
||||
let ethers = null; try { ethers = require('ethers'); } catch (e) {}
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@@ -82,36 +81,38 @@ async function onJoin(acct, usedRef) {
|
||||
}
|
||||
|
||||
// ---- before activation / purchase: make sure the sponsor exists on this contract ----
|
||||
// returns { sponsorId, hold, claim } — hold is set when the buy must wait (claim window)
|
||||
async function resolveForChain(acct, spd) {
|
||||
// A purchase is NEVER held (Marty, 2026-10-15: "We should never, ever hold up a purchase"; the 3-day claim
|
||||
// window is gone). Returns { sponsorId, routed } or null when the normal resolver already has the answer.
|
||||
// - Sponsor with a wallet: the engine activates them (gas on us) and they are paid, wallet off or not.
|
||||
// - Sponsor with no wallet, unknown, or an activation that failed: the sale goes to the nearest ancestor
|
||||
// with a wallet (activated on the spot), else sponsorId 0 = the caller's company fallback.
|
||||
// Only `commit` (the buyer is about to sign) moves the member and sends the notices; a display check just answers.
|
||||
async function resolveForChain(acct, spd, opts) {
|
||||
if (!acct || !acct.sponsorRef) return null;
|
||||
if (spd.id) return null; // already on-chain: nothing to do
|
||||
if (spd.reason !== 'notActivated') return null; // unknown token or rpc: the normal guard handles it
|
||||
if (spd.reason === 'rpc' || spd.reason === 'none') return null; // a chain hiccup is retried by the client; nothing is charged
|
||||
const commit = !!(opts && opts.commit);
|
||||
let sp = await X.accounts.byCode(acct.sponsorRef); if (!sp) sp = await X.accounts.byUsername(acct.sponsorRef);
|
||||
if (!sp) return null;
|
||||
if (sp.address) {
|
||||
const id = await ensureOnChain(sp, 0);
|
||||
return id ? { sponsorId: id } : null;
|
||||
if (sp && sp.address) {
|
||||
let id = await ensureOnChain(sp, 0);
|
||||
if (!id) id = await ensureOnChain(sp, 0); // one retry before passing a wallet holder over for our own failure
|
||||
if (id) return { sponsorId: id };
|
||||
logEvent({ type: 'activateGaveUp', member: acct.email, sponsor: sp.email });
|
||||
}
|
||||
// no wallet: the claim window
|
||||
const st = state(); const k = norm(acct.email);
|
||||
let c = st.claims[k];
|
||||
if (!c) {
|
||||
c = { member: k, sponsor: sp.email, opened: Date.now(), deadline: Date.now() + claimDays() * DAY, notified: true }; st.claims[k] = c; setState(st);
|
||||
await tell(sp.email, label(acct) + ' is ready to buy on LinkSpin. Link a wallet to be their sponsor',
|
||||
label(acct) + ' joined LinkSpin under you and wants to buy a package. The contract can only pay a wallet, and there is none on your LinkSpin account yet.\n\nLink one within ' + claimDays() + ' days (Wallet tab, one free signature) and their purchases pay you. If the window passes, the seat goes to the next person above you who has a wallet.\n\nhttps://' + (X.host || 'linkspin.co') + '/my#wallet');
|
||||
// walk up to the first ancestor with a wallet the engine can place on the contract
|
||||
let up = sp ? await nearestWithWallet(sp.email) : null; let id = 0; let hops = 0;
|
||||
while (up && hops < 25) { id = await ensureOnChain(up, 0); if (id) break; up = await nearestWithWallet(up.email); hops++; }
|
||||
if (!id) up = null;
|
||||
const routed = { from: sp ? label(sp) : null, to: up ? label(up) : 'the company', toEmail: up ? up.email : null };
|
||||
if (commit) {
|
||||
if (up) await X.accounts.setSponsorRef(acct.email, up.username || up.code);
|
||||
logEvent({ type: 'walkedUp', member: acct.email, from: sp ? sp.email : acct.sponsorRef, to: up ? up.email : 'company' });
|
||||
if (sp) await tell(sp.email, 'You missed ' + label(acct) + ' on LinkSpin: no wallet linked',
|
||||
label(acct) + ' joined LinkSpin under you and bought a package, but there is no wallet on your LinkSpin account, so the contract could not pay you. The sale went to ' + routed.to + ', and ' + label(acct) + ' is now in their line.\n\nLink a wallet now (Wallet tab, one free signature) and every purchase from the people who join under you from here on pays you.\n\nhttps://' + (X.host || 'linkspin.co') + '/my#wallet');
|
||||
if (up) await tell(up.email, label(acct) + ' was placed under you on LinkSpin',
|
||||
label(acct) + ' joined through ' + (sp ? label(sp) : 'a link') + ', who has no wallet on LinkSpin, so the network placed them under you. Their purchases pay you from now on.');
|
||||
}
|
||||
if (Date.now() < c.deadline) return { sponsorId: 0, hold: true, claim: { sponsor: label(sp), deadline: c.deadline } };
|
||||
// window passed: walk up to the nearest ancestor with a wallet, activate them, tell both sides
|
||||
const up = await nearestWithWallet(sp.email);
|
||||
if (!up) return { sponsorId: 0, hold: true, claim: { sponsor: label(sp), deadline: c.deadline, nobody: true } };
|
||||
const id = await ensureOnChain(up, 0);
|
||||
if (!id) return null;
|
||||
await X.accounts.setSponsorRef(acct.email, up.username || up.code);
|
||||
delete st.claims[k]; setState(st); logEvent({ type: 'walkedUp', member: acct.email, from: sp.email, to: up.email });
|
||||
await tell(sp.email, 'The seat for ' + label(acct) + ' passed to ' + label(up), 'No wallet was linked within ' + claimDays() + ' days, so ' + label(acct) + ' was placed under ' + label(up) + ', the nearest person above you with a wallet. Link a wallet now and everyone who joins under you from here on is yours.');
|
||||
await tell(up.email, label(acct) + ' was placed under you on LinkSpin', label(acct) + ' joined through ' + label(sp) + ', who has no wallet on LinkSpin, so the network placed them under you. Their purchases pay you from now on.');
|
||||
return { sponsorId: id, movedTo: up.email };
|
||||
return { sponsorId: id, routed };
|
||||
}
|
||||
|
||||
async function nearestWithWallet(email) {
|
||||
|
||||
+148
-148
@@ -1,148 +1,148 @@
|
||||
// LinkSpin Credits (2026-10-07): the buy screen inside the Control Room. Package picker from the catalog, the POL
|
||||
// quote, connect/link a wallet, the on-chain purchase (ported from the classic /my#buy flow: sponsor hold, balance
|
||||
// pre-flight, Trust Wallet heads-up), switch-on-payouts without buying, card on-ramp, purchases from the chain.
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
|
||||
// wallet.js reports through IAP.status (the classic dashboard's status bar): route it to the shell's toast
|
||||
if (window.IAP) IAP.status = (m, kind) => CR.toast(m, kind === 'bad');
|
||||
CR.mount({ active: 'credits', title: 'Credits', sub: 'loading' });
|
||||
const pol = wei => { try { return (Number(BigInt(String(wei || '0')) / 10000000000000000n) / 100).toFixed(2); } catch (e) { return '0.00'; } };
|
||||
const usd = c => '$' + (Number(c || 0) / 100).toLocaleString(undefined, { maximumFractionDigits: 2 });
|
||||
const NAMES = { 1000: 'Door', 2500: 'Most chosen', 5000: 'Builder', 10000: 'Growth', 25000: 'Leader', 50000: 'Network' };
|
||||
let CFG = null, ME = null, CAT = [], SEL = null, CAMP = null, DASH = null;
|
||||
|
||||
function paintTiles() {
|
||||
const avail = CAMP ? CAMP.availableCredits : 0, inLive = CAMP ? CAMP.inCampaigns : 0;
|
||||
const addr = ME && ME.address, on = !!(ME && ME.memberId);
|
||||
const bc = DASH ? (DASH.buyerCount || 0) : 0;
|
||||
$('tiles').innerHTML = [
|
||||
CR.tile({ k: 'Credits available', v: fmt(avail), hi: true, note: CAMP ? 'earned ' + fmt(CAMP.earnedCredits) + ' · purchased ' + fmt(CAMP.purchasedCredits) : '' }),
|
||||
CR.tile({ k: 'Working in live ads', v: fmt(inLive), note: CAMP ? (CAMP.campaigns || []).filter(c => c.status === 'live').length + ' live' : '' }),
|
||||
CR.tile({ k: 'Wallet', v: addr ? addr.slice(0, 6) + '…' + addr.slice(-4) : 'not linked', note: on ? 'payouts on · member #' + ME.memberId : (addr ? 'payouts off' : 'needed to buy or be paid') }),
|
||||
CR.tile({ k: 'Qualification', v: bc + ' of ' + (bc >= 5 ? 5 : bc >= 2 ? 5 : 2), note: bc >= 5 ? 'levels 2 and 3 open' : bc >= 2 ? 'level 2 open · 5 opens level 3' : 'buyers to open level 2' })
|
||||
].join('');
|
||||
}
|
||||
function paintPkgs() {
|
||||
const live = CAT.filter(p => p.active !== false && p.exists !== false);
|
||||
if (!live.length) { $('pkgs').innerHTML = '<div class="muted">No packages are on sale right now.</div>'; return; }
|
||||
if (!SEL) SEL = (live.find(p => p.priceCents === 2500) || live[0]).id;
|
||||
$('pkgs').innerHTML = live.map(p => '<button type="button" class="pk' + (p.id === SEL ? ' on' : '') + '" data-id="' + p.id + '"><span class="k">' + esc(NAMES[p.priceCents] || 'Package') + '</span><span class="price">' + usd(p.priceCents) + '</span><span class="cr">' + fmt(p.creditAmount) + ' credits</span>'
|
||||
+ (p.priceCents >= 2000 ? '<span class="tag ok">qualifies</span>' : '<span class="tag">does not qualify</span>') + '</button>').join('');
|
||||
$('pkgs').querySelectorAll('.pk').forEach(b => b.addEventListener('click', () => { SEL = Number(b.dataset.id); paintPkgs(); paintQuote(); paintGoes(); }));
|
||||
}
|
||||
const sel = () => CAT.find(p => p.id === SEL);
|
||||
function paintQuote() {
|
||||
const p = sel(); if (!p) return;
|
||||
if (p.costWei) { $('payPol').textContent = pol(p.costWei) + ' POL'; $('payUsd').textContent = '≈ ' + usd(p.priceCents) + ' + gas'; }
|
||||
else { $('payPol').textContent = 'paused'; $('payUsd').textContent = 'price feed is catching up'; }
|
||||
const rate = (p.costWei && p.priceCents) ? (p.priceCents / 100) / (Number(BigInt(p.costWei) / 1000000000000n) / 1e6) : 0;
|
||||
$('rateLine').textContent = rate ? 'rate ' + rate.toFixed(4) + ' USD/POL · live from the oracle' : '';
|
||||
const addr = ME && ME.address;
|
||||
$('buyBtn').disabled = !p.costWei;
|
||||
$('buyBtn').textContent = addr ? 'Buy ' + usd(p.priceCents) + ' package' : 'Connect a wallet to buy';
|
||||
}
|
||||
function paintGoes() {
|
||||
const p = sel(); if (!p) return;
|
||||
const d = p.priceCents / 100; const spName = ME && ME.sponsorName ? ('@' + String(ME.sponsorName).replace(/^@/, '')) : 'your sponsor';
|
||||
$('goesTitle').textContent = 'Where ' + usd(p.priceCents) + ' goes';
|
||||
$('goesRows').innerHTML = [
|
||||
['Level 1 · ' + esc(spName), '$' + (d * 0.5).toFixed(2)],
|
||||
['Level 2 · upline <span class="tag" title="paid if qualified, else passes up">if qualified</span>', '$' + (d * 0.2).toFixed(2)],
|
||||
['Level 3 · upline <span class="tag" title="paid if qualified, else passes up">if qualified</span>', '$' + (d * 0.1).toFixed(2)],
|
||||
['Platform, two wallets', '$' + (d * 0.2).toFixed(2)]
|
||||
].map(([k, v]) => '<div class="row"><span>' + k + '</span><span class="mono" style="font-weight:700">' + v + '</span></div>').join('')
|
||||
+ '<p class="muted" style="margin:10px 0 0;font-size:11.5px">A pass-up goes to the next qualified member above, else to the platform. Nothing is ever held for later.</p>';
|
||||
}
|
||||
function paintWallet() {
|
||||
const addr = ME && ME.address, on = !!(ME && ME.memberId);
|
||||
$('walletMeta').textContent = addr ? (on ? 'payouts on' : 'linked · payouts off') : 'none linked';
|
||||
$('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>'
|
||||
: '<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="relinkBtn">Use a different wallet</button></div>'
|
||||
: '<div class="ink2" style="font-size:13px">Link the wallet that should receive your payouts. One free signature, no transaction. SafePal is the recommended wallet; MetaMask, Phantom and any WalletConnect wallet work too.</div><div class="acts"><button class="btn blue" type="button" id="linkBtn">Link a wallet</button><a class="btn sm" href="/wallets" target="_blank" rel="noopener">Wallet guide</a></div>';
|
||||
const lb = $('linkBtn'); if (lb) lb.addEventListener('click', () => guard(lb, linkWallet));
|
||||
const ab = $('activateBtn'); if (ab) ab.addEventListener('click', () => guard(ab, activate));
|
||||
const rb = $('relinkBtn'); if (rb) rb.addEventListener('click', () => guard(rb, async () => { await IAPWallet.disconnect(); CR.toast('Disconnected. Reloading so you can pick another wallet.'); setTimeout(() => location.reload(), 800); }));
|
||||
}
|
||||
function paintBuys(E) {
|
||||
const buys = E && Array.isArray(E.purchases) ? E.purchases : [];
|
||||
$('buysMeta').textContent = buys.length + (buys.length === 1 ? ' purchase' : ' purchases') + ' · every row links to the transaction';
|
||||
$('buyRows').innerHTML = buys.length ? buys.slice(0, 50).map(x => {
|
||||
const ts = Number(x.ts || x.time || 0); const when = ts ? new Date(ts * (ts > 1e12 ? 1 : 1000)).toLocaleString() : '';
|
||||
const pkg = x.priceCents ? usd(x.priceCents) : (x.package || x.product || ('#' + (x.productId || '')));
|
||||
const paid = x.amountWei || x.valueWei || x.paidWei ? pol(x.amountWei || x.valueWei || x.paidWei) + ' POL' : '';
|
||||
const tx = x.tx || x.hash || '';
|
||||
return '<div class="rw"><span class="mono muted" style="font-size:12px">' + esc(when) + '</span><span class="num">' + esc(String(pkg)) + '</span><span class="mono">' + esc(paid) + '</span><span>' + (tx ? '<a class="mono" href="' + esc((CFG && CFG.explorer) || 'https://polygonscan.com') + '/tx/' + esc(tx) + '" target="_blank" rel="noopener">' + esc(tx.slice(0, 10)) + '…' + esc(tx.slice(-6)) + '</a>' : '') + '</span></div>';
|
||||
}).join('') : '<div class="rw" style="grid-template-columns:1fr"><span class="muted">Nothing yet. Your first package shows here with its transaction, what you paid in POL, and who in your line was paid.</span></div>';
|
||||
}
|
||||
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; } }
|
||||
|
||||
// a named sponsor that cannot be paid right now: hold the transaction and say why (never credit the company by default)
|
||||
function holdText(sp) {
|
||||
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).';
|
||||
if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.';
|
||||
return 'Your sponsor link could not be matched to a member. Message support before buying so ' + who + ' gets credit.';
|
||||
}
|
||||
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 me = await CR.me(true); if (me.sponsorBlocked) { $('holdBox').textContent = holdText(me); $('holdBox').hidden = false; return; }
|
||||
CR.toast('Confirm the free activation in your wallet…');
|
||||
const r = await IAPWallet.activate(me.sponsorId || 0);
|
||||
if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Check the explorer.');
|
||||
CR.toast('Payouts are on. Your invite link is live.'); await load();
|
||||
}
|
||||
async function buy() {
|
||||
const p = sel(); if (!p || !p.costWei) return;
|
||||
$('holdBox').hidden = true;
|
||||
let me = await CR.me(true);
|
||||
if (!me.address) { CR.toast('Link your wallet first: one quick signature…'); await IAPWallet.signIn(); me = await CR.me(true); }
|
||||
const want = String(me.address || '').toLowerCase(); if (!want) throw new Error('No wallet linked.');
|
||||
await IAPWallet.connect();
|
||||
let cur = String(await IAPWallet.activeAddress() || '').toLowerCase();
|
||||
if (cur !== want) { CR.toast('Pick ' + want.slice(0, 6) + '…' + want.slice(-4) + ' in your wallet\'s account picker…'); cur = String(await IAPWallet.pickAccount() || '').toLowerCase(); }
|
||||
if (cur !== want) throw new Error('Your wallet connected as ' + cur.slice(0, 6) + '…' + cur.slice(-4) + ' but your linked wallet is ' + want.slice(0, 6) + '…' + want.slice(-4) + '. Switch accounts in the wallet app and try again.');
|
||||
const sp = await CR.get('/api/sponsor');
|
||||
if (!me.memberId && sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; return; }
|
||||
try { // pre-flight: the POL has to be there; Trust Wallet refuses transactions that spend most of a balance
|
||||
const need = BigInt(p.costWei) + BigInt(p.costWei) / 50n;
|
||||
const bal = await IAPWallet.balance(want);
|
||||
if (bal < need) { CR.toast('That wallet holds ' + pol(bal.toString()) + ' POL, but this package needs about ' + pol(need.toString()) + ' POL plus a little for gas. Top it up and try again.', true); return; }
|
||||
const pct = Number(need * 100n / bal);
|
||||
if (/trust/i.test(IAPWallet.walletName() || '') && pct > 55) {
|
||||
const ok = await CR.dialog({ title: 'Heads up for Trust Wallet', text: 'This purchase uses about ' + pct + '% of the POL in your wallet, and Trust Wallet refuses transactions that spend most of a balance. Add some POL first, or continue and see if it lets it through.', ok: 'Continue' });
|
||||
if (!ok) return;
|
||||
}
|
||||
} catch (e) { /* balance read failed: let the wallet decide */ }
|
||||
CR.toast('Confirm the purchase in your wallet…');
|
||||
const r = await IAPWallet.buy(Number(p.id), sp.sponsorId || 0, p.costWei);
|
||||
if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Nothing was charged beyond gas.');
|
||||
CR.toast('Settled on-chain. Your credits are in Ads now.');
|
||||
await load();
|
||||
}
|
||||
$('buyBtn').addEventListener('click', () => guard($('buyBtn'), buy));
|
||||
$('cardBtn').addEventListener('click', () => guard($('cardBtn'), async () => {
|
||||
const p = sel(); const need = p && p.costWei ? Math.max(10, Math.ceil(Number(BigInt(p.costWei) / 1000000000000000000n)) + 3) : 30;
|
||||
const q = '/api/moonpay-url?pol=' + need + (ME && ME.address ? '&address=' + encodeURIComponent(ME.address) : '');
|
||||
const r = await CR.get(q); if (!r.url) throw new Error('The card on-ramp is not available right now.');
|
||||
window.open(r.url, '_blank', 'noopener'); CR.toast('MoonPay opened in a new tab. POL lands straight in your own wallet.');
|
||||
}));
|
||||
|
||||
async function load() {
|
||||
try { [CFG, ME] = await Promise.all([CR.get('/api/config'), CR.me(true)]); } catch (e) { CR.sub('could not load'); return; }
|
||||
let cat = null, E = null;
|
||||
try { [cat, CAMP, DASH, E] = await Promise.all([CR.get('/api/catalog'), CR.get('/api/my/campaigns'), CR.get('/api/my/dashboard'), CR.get('/api/my/activity')]); } catch (e) {}
|
||||
CAT = (cat && cat.products) || [];
|
||||
CR.sub((CAMP ? fmt(CAMP.availableCredits) + ' free to spend · ' + fmt(CAMP.inCampaigns) + ' in live ads' : '') + (CAT[0] && CAT[0].costWei ? '' : ' · price feed catching up'));
|
||||
paintTiles(); paintPkgs(); paintQuote(); paintGoes(); paintWallet(); paintBuys(E);
|
||||
const spName = ME.sponsorName ? ('@' + String(ME.sponsorName).replace(/^@/, '')) : null;
|
||||
$('sponsorLine').innerHTML = spName
|
||||
? 'Your sponsor <b>' + esc(spName) + '</b> is placed on the contract. The moment you confirm, half of the package lands in their wallet and the rest splits as shown. Credits appear in Ads right away.'
|
||||
: 'No sponsor is recorded on your account. Your purchase still works; the sponsor share goes to the platform position. If someone invited you, open their invite link first.';
|
||||
if (ME.sponsorBlocked) { $('holdBox').textContent = holdText(ME); $('holdBox').hidden = false; }
|
||||
}
|
||||
CR.requireSession(load);
|
||||
})();
|
||||
// LinkSpin Credits (2026-10-07): the buy screen inside the Control Room. Package picker from the catalog, the POL
|
||||
// quote, connect/link a wallet, the on-chain purchase (ported from the classic /my#buy flow: sponsor hold, balance
|
||||
// pre-flight, Trust Wallet heads-up), switch-on-payouts without buying, card on-ramp, purchases from the chain.
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
|
||||
// wallet.js reports through IAP.status (the classic dashboard's status bar): route it to the shell's toast
|
||||
if (window.IAP) IAP.status = (m, kind) => CR.toast(m, kind === 'bad');
|
||||
CR.mount({ active: 'credits', title: 'Credits', sub: 'loading' });
|
||||
const pol = wei => { try { return (Number(BigInt(String(wei || '0')) / 10000000000000000n) / 100).toFixed(2); } catch (e) { return '0.00'; } };
|
||||
const usd = c => '$' + (Number(c || 0) / 100).toLocaleString(undefined, { maximumFractionDigits: 2 });
|
||||
const NAMES = { 1000: 'Door', 2500: 'Most chosen', 5000: 'Builder', 10000: 'Growth', 25000: 'Leader', 50000: 'Network' };
|
||||
let CFG = null, ME = null, CAT = [], SEL = null, CAMP = null, DASH = null;
|
||||
|
||||
function paintTiles() {
|
||||
const avail = CAMP ? CAMP.availableCredits : 0, inLive = CAMP ? CAMP.inCampaigns : 0;
|
||||
const addr = ME && ME.address, on = !!(ME && ME.memberId);
|
||||
const bc = DASH ? (DASH.buyerCount || 0) : 0;
|
||||
$('tiles').innerHTML = [
|
||||
CR.tile({ k: 'Credits available', v: fmt(avail), hi: true, note: CAMP ? 'earned ' + fmt(CAMP.earnedCredits) + ' · purchased ' + fmt(CAMP.purchasedCredits) : '' }),
|
||||
CR.tile({ k: 'Working in live ads', v: fmt(inLive), note: CAMP ? (CAMP.campaigns || []).filter(c => c.status === 'live').length + ' live' : '' }),
|
||||
CR.tile({ k: 'Wallet', v: addr ? addr.slice(0, 6) + '…' + addr.slice(-4) : 'not linked', note: on ? 'payouts on · member #' + ME.memberId : (addr ? 'payouts off' : 'needed to buy or be paid') }),
|
||||
CR.tile({ k: 'Qualification', v: bc + ' of ' + (bc >= 5 ? 5 : bc >= 2 ? 5 : 2), note: bc >= 5 ? 'levels 2 and 3 open' : bc >= 2 ? 'level 2 open · 5 opens level 3' : 'buyers to open level 2' })
|
||||
].join('');
|
||||
}
|
||||
function paintPkgs() {
|
||||
const live = CAT.filter(p => p.active !== false && p.exists !== false);
|
||||
if (!live.length) { $('pkgs').innerHTML = '<div class="muted">No packages are on sale right now.</div>'; return; }
|
||||
if (!SEL) SEL = (live.find(p => p.priceCents === 2500) || live[0]).id;
|
||||
$('pkgs').innerHTML = live.map(p => '<button type="button" class="pk' + (p.id === SEL ? ' on' : '') + '" data-id="' + p.id + '"><span class="k">' + esc(NAMES[p.priceCents] || 'Package') + '</span><span class="price">' + usd(p.priceCents) + '</span><span class="cr">' + fmt(p.creditAmount) + ' credits</span>'
|
||||
+ (p.priceCents >= 2000 ? '<span class="tag ok">qualifies</span>' : '<span class="tag">does not qualify</span>') + '</button>').join('');
|
||||
$('pkgs').querySelectorAll('.pk').forEach(b => b.addEventListener('click', () => { SEL = Number(b.dataset.id); paintPkgs(); paintQuote(); paintGoes(); }));
|
||||
}
|
||||
const sel = () => CAT.find(p => p.id === SEL);
|
||||
function paintQuote() {
|
||||
const p = sel(); if (!p) return;
|
||||
if (p.costWei) { $('payPol').textContent = pol(p.costWei) + ' POL'; $('payUsd').textContent = '≈ ' + usd(p.priceCents) + ' + gas'; }
|
||||
else { $('payPol').textContent = 'paused'; $('payUsd').textContent = 'price feed is catching up'; }
|
||||
const rate = (p.costWei && p.priceCents) ? (p.priceCents / 100) / (Number(BigInt(p.costWei) / 1000000000000n) / 1e6) : 0;
|
||||
$('rateLine').textContent = rate ? 'rate ' + rate.toFixed(4) + ' USD/POL · live from the oracle' : '';
|
||||
const addr = ME && ME.address;
|
||||
$('buyBtn').disabled = !p.costWei;
|
||||
$('buyBtn').textContent = addr ? 'Buy ' + usd(p.priceCents) + ' package' : 'Connect a wallet to buy';
|
||||
}
|
||||
function paintGoes() {
|
||||
const p = sel(); if (!p) return;
|
||||
const d = p.priceCents / 100; const spName = ME && ME.sponsorName ? ('@' + String(ME.sponsorName).replace(/^@/, '')) : 'your sponsor';
|
||||
$('goesTitle').textContent = 'Where ' + usd(p.priceCents) + ' goes';
|
||||
$('goesRows').innerHTML = [
|
||||
['Level 1 · ' + esc(spName), '$' + (d * 0.5).toFixed(2)],
|
||||
['Level 2 · upline <span class="tag" title="paid if qualified, else passes up">if qualified</span>', '$' + (d * 0.2).toFixed(2)],
|
||||
['Level 3 · upline <span class="tag" title="paid if qualified, else passes up">if qualified</span>', '$' + (d * 0.1).toFixed(2)],
|
||||
['Platform, two wallets', '$' + (d * 0.2).toFixed(2)]
|
||||
].map(([k, v]) => '<div class="row"><span>' + k + '</span><span class="mono" style="font-weight:700">' + v + '</span></div>').join('')
|
||||
+ '<p class="muted" style="margin:10px 0 0;font-size:11.5px">A pass-up goes to the next qualified member above, else to the platform. Nothing is ever held for later.</p>';
|
||||
}
|
||||
function paintWallet() {
|
||||
const addr = ME && ME.address, on = !!(ME && ME.memberId);
|
||||
$('walletMeta').textContent = addr ? (on ? 'payouts on' : 'linked · payouts off') : 'none linked';
|
||||
$('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>'
|
||||
: '<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="relinkBtn">Use a different wallet</button></div>'
|
||||
: '<div class="ink2" style="font-size:13px">Link the wallet that should receive your payouts. One free signature, no transaction. SafePal is the recommended wallet; MetaMask, Phantom and any WalletConnect wallet work too.</div><div class="acts"><button class="btn blue" type="button" id="linkBtn">Link a wallet</button><a class="btn sm" href="/wallets" target="_blank" rel="noopener">Wallet guide</a></div>';
|
||||
const lb = $('linkBtn'); if (lb) lb.addEventListener('click', () => guard(lb, linkWallet));
|
||||
const ab = $('activateBtn'); if (ab) ab.addEventListener('click', () => guard(ab, activate));
|
||||
const rb = $('relinkBtn'); if (rb) rb.addEventListener('click', () => guard(rb, async () => { await IAPWallet.disconnect(); CR.toast('Disconnected. Reloading so you can pick another wallet.'); setTimeout(() => location.reload(), 800); }));
|
||||
}
|
||||
function paintBuys(E) {
|
||||
const buys = E && Array.isArray(E.purchases) ? E.purchases : [];
|
||||
$('buysMeta').textContent = buys.length + (buys.length === 1 ? ' purchase' : ' purchases') + ' · every row links to the transaction';
|
||||
$('buyRows').innerHTML = buys.length ? buys.slice(0, 50).map(x => {
|
||||
const ts = Number(x.ts || x.time || 0); const when = ts ? new Date(ts * (ts > 1e12 ? 1 : 1000)).toLocaleString() : '';
|
||||
const pkg = x.priceCents ? usd(x.priceCents) : (x.package || x.product || ('#' + (x.productId || '')));
|
||||
const paid = x.amountWei || x.valueWei || x.paidWei ? pol(x.amountWei || x.valueWei || x.paidWei) + ' POL' : '';
|
||||
const tx = x.tx || x.hash || '';
|
||||
return '<div class="rw"><span class="mono muted" style="font-size:12px">' + esc(when) + '</span><span class="num">' + esc(String(pkg)) + '</span><span class="mono">' + esc(paid) + '</span><span>' + (tx ? '<a class="mono" href="' + esc((CFG && CFG.explorer) || 'https://polygonscan.com') + '/tx/' + esc(tx) + '" target="_blank" rel="noopener">' + esc(tx.slice(0, 10)) + '…' + esc(tx.slice(-6)) + '</a>' : '') + '</span></div>';
|
||||
}).join('') : '<div class="rw" style="grid-template-columns:1fr"><span class="muted">Nothing yet. Your first package shows here with its transaction, what you paid in POL, and who in your line was paid.</span></div>';
|
||||
}
|
||||
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; } }
|
||||
|
||||
// a named sponsor that cannot be paid right now: hold the transaction and say why (never credit the company by default)
|
||||
function holdText(sp) {
|
||||
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).';
|
||||
if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.';
|
||||
return 'Your sponsor link could not be matched to a member. Message support before buying so ' + who + ' gets credit.';
|
||||
}
|
||||
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; }
|
||||
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.');
|
||||
CR.toast('Payouts are on. Your invite link is live.'); await load();
|
||||
}
|
||||
async function buy() {
|
||||
const p = sel(); if (!p || !p.costWei) return;
|
||||
$('holdBox').hidden = true;
|
||||
let me = await CR.me(true);
|
||||
if (!me.address) { CR.toast('Link your wallet first: one quick signature…'); await IAPWallet.signIn(); me = await CR.me(true); }
|
||||
const want = String(me.address || '').toLowerCase(); if (!want) throw new Error('No wallet linked.');
|
||||
await IAPWallet.connect();
|
||||
let cur = String(await IAPWallet.activeAddress() || '').toLowerCase();
|
||||
if (cur !== want) { CR.toast('Pick ' + want.slice(0, 6) + '…' + want.slice(-4) + ' in your wallet\'s account picker…'); cur = String(await IAPWallet.pickAccount() || '').toLowerCase(); }
|
||||
if (cur !== want) throw new Error('Your wallet connected as ' + cur.slice(0, 6) + '…' + cur.slice(-4) + ' but your linked wallet is ' + want.slice(0, 6) + '…' + want.slice(-4) + '. Switch accounts in the wallet app and try again.');
|
||||
const sp = await CR.get('/api/sponsor?intent=buy');
|
||||
if (!me.memberId && sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; return; }
|
||||
try { // pre-flight: the POL has to be there; Trust Wallet refuses transactions that spend most of a balance
|
||||
const need = BigInt(p.costWei) + BigInt(p.costWei) / 50n;
|
||||
const bal = await IAPWallet.balance(want);
|
||||
if (bal < need) { CR.toast('That wallet holds ' + pol(bal.toString()) + ' POL, but this package needs about ' + pol(need.toString()) + ' POL plus a little for gas. Top it up and try again.', true); return; }
|
||||
const pct = Number(need * 100n / bal);
|
||||
if (/trust/i.test(IAPWallet.walletName() || '') && pct > 55) {
|
||||
const ok = await CR.dialog({ title: 'Heads up for Trust Wallet', text: 'This purchase uses about ' + pct + '% of the POL in your wallet, and Trust Wallet refuses transactions that spend most of a balance. Add some POL first, or continue and see if it lets it through.', ok: 'Continue' });
|
||||
if (!ok) return;
|
||||
}
|
||||
} catch (e) { /* balance read failed: let the wallet decide */ }
|
||||
CR.toast('Confirm the purchase in your wallet…');
|
||||
const r = await IAPWallet.buy(Number(p.id), sp.sponsorId || 0, p.costWei);
|
||||
if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Nothing was charged beyond gas.');
|
||||
CR.toast('Settled on-chain. Your credits are in Ads now.');
|
||||
await load();
|
||||
}
|
||||
$('buyBtn').addEventListener('click', () => guard($('buyBtn'), buy));
|
||||
$('cardBtn').addEventListener('click', () => guard($('cardBtn'), async () => {
|
||||
const p = sel(); const need = p && p.costWei ? Math.max(10, Math.ceil(Number(BigInt(p.costWei) / 1000000000000000000n)) + 3) : 30;
|
||||
const q = '/api/moonpay-url?pol=' + need + (ME && ME.address ? '&address=' + encodeURIComponent(ME.address) : '');
|
||||
const r = await CR.get(q); if (!r.url) throw new Error('The card on-ramp is not available right now.');
|
||||
window.open(r.url, '_blank', 'noopener'); CR.toast('MoonPay opened in a new tab. POL lands straight in your own wallet.');
|
||||
}));
|
||||
|
||||
async function load() {
|
||||
try { [CFG, ME] = await Promise.all([CR.get('/api/config'), CR.me(true)]); } catch (e) { CR.sub('could not load'); return; }
|
||||
let cat = null, E = null;
|
||||
try { [cat, CAMP, DASH, E] = await Promise.all([CR.get('/api/catalog'), CR.get('/api/my/campaigns'), CR.get('/api/my/dashboard'), CR.get('/api/my/activity')]); } catch (e) {}
|
||||
CAT = (cat && cat.products) || [];
|
||||
CR.sub((CAMP ? fmt(CAMP.availableCredits) + ' free to spend · ' + fmt(CAMP.inCampaigns) + ' in live ads' : '') + (CAT[0] && CAT[0].costWei ? '' : ' · price feed catching up'));
|
||||
paintTiles(); paintPkgs(); paintQuote(); paintGoes(); paintWallet(); paintBuys(E);
|
||||
const spName = ME.sponsorName ? ('@' + String(ME.sponsorName).replace(/^@/, '')) : null;
|
||||
$('sponsorLine').innerHTML = spName
|
||||
? 'Your sponsor <b>' + esc(spName) + '</b> is placed on the contract. The moment you confirm, half of the package lands in their wallet and the rest splits as shown. Credits appear in Ads right away.'
|
||||
: 'No sponsor is recorded on your account. Your purchase still works; the sponsor share goes to the platform position. If someone invited you, open their invite link first.';
|
||||
if (ME.sponsorBlocked) { $('holdBox').textContent = holdText(ME); $('holdBox').hidden = false; }
|
||||
}
|
||||
CR.requireSession(load);
|
||||
})();
|
||||
|
||||
+2701
-2701
File diff suppressed because it is too large
Load Diff
+86
-86
@@ -1,86 +1,86 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<title>Credits · LinkSpin</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/cr.css?v=20261012a">
|
||||
<style>
|
||||
.body{padding:16px 24px;display:grid;gap:16px}
|
||||
.two{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:16px;align-items:start}
|
||||
.pkgs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
|
||||
.pk{border:1px solid var(--line);border-radius:8px;padding:12px 12px 10px;background:#FFF;display:flex;flex-direction:column;gap:4px;cursor:pointer;text-align:left;font:inherit;color:inherit;min-height:44px;box-shadow:var(--sh)}
|
||||
.pk:hover{border-color:var(--accent)}
|
||||
.pk.on{border-color:var(--sig);box-shadow:0 0 0 3px rgba(255,106,26,.18);background:linear-gradient(180deg,#FFFFFF,var(--hi-row))}
|
||||
.pk .k{font:700 10px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
|
||||
.pk.on .k{color:var(--sig-2)}
|
||||
.pk .price{font-family:var(--display);font-weight:700;font-size:28px;line-height:1;letter-spacing:.02em}
|
||||
.pk.on .price{color:var(--accent-hi)}
|
||||
.pk .cr{font-size:12px;color:var(--ink-2)}
|
||||
.pk .tag{align-self:flex-start;margin-top:2px}
|
||||
.row{display:flex;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid var(--line);font-size:13px}
|
||||
.row:last-child{border-bottom:0}
|
||||
.buys .hd,.buys .rw{grid-template-columns:150px 110px 130px minmax(0,1fr)}
|
||||
.acts{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
|
||||
@media (max-width:900px){.two{grid-template-columns:1fr}.pkgs{grid-template-columns:repeat(2,minmax(0,1fr))}.buys .hd{display:none}.buys .rw{grid-template-columns:1fr 1fr}.body{padding:12px 16px}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="body">
|
||||
<div class="tiles" id="tiles"></div>
|
||||
<div class="two">
|
||||
<div style="display:grid;gap:16px;align-content:start">
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3>Buy a package</h3><span class="meta" id="buyMeta">priced in dollars · settled in POL at the live rate · one transaction</span></div>
|
||||
<div style="padding:14px 16px 16px;display:grid;gap:14px">
|
||||
<div class="pkgs" id="pkgs"><div class="muted">loading packages…</div></div>
|
||||
<div class="acts">
|
||||
<span class="led"><span style="font-size:10px;letter-spacing:.1em;text-transform:uppercase">you pay</span><b id="payPol">·</b><span id="payUsd"></span></span>
|
||||
<span class="mono muted" style="font-size:11px" id="rateLine"></span>
|
||||
</div>
|
||||
<div class="acts" id="buyActs">
|
||||
<button class="btn pri" type="button" id="buyBtn" disabled>Connect a wallet to buy</button>
|
||||
<button class="btn" type="button" id="cardBtn">Buy POL with a card</button>
|
||||
<span class="muted" style="font-size:12px">SafePal recommended. MetaMask, Phantom and WalletConnect wallets also work.</span>
|
||||
</div>
|
||||
<div id="holdBox" class="warn" style="font-size:13px" hidden></div>
|
||||
<p class="ink2" style="margin:0;font-size:12.5px;line-height:1.5" id="sponsorLine">Loading your sponsor…</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tbl buys">
|
||||
<div class="ph"><h3>Your purchases</h3><span class="meta" id="buysMeta">every row links to the transaction</span></div>
|
||||
<div class="hd"><span>When</span><span>Package</span><span>Paid</span><span>Transaction</span></div>
|
||||
<div id="buyRows"></div>
|
||||
<div class="ft">credits appear in Ads the moment the transaction settles · nothing is held by the site</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:grid;gap:16px;align-content:start">
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3 id="goesTitle">Where it goes</h3><span class="meta">same transaction</span></div>
|
||||
<div style="padding:10px 16px 14px" id="goesRows"></div>
|
||||
</div>
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3>Your wallet</h3><span class="meta" id="walletMeta"></span></div>
|
||||
<div style="padding:12px 16px 14px;display:grid;gap:10px" id="walletBox"></div>
|
||||
</div>
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3>Earn instead</h3><span class="meta">free credits</span></div>
|
||||
<div style="padding:12px 16px 14px;display:grid;gap:8px;font-size:13px" class="ink2">
|
||||
<div style="display:flex;justify-content:space-between;gap:10px"><span>View 5 ads, claim 5 credits</span><a href="/ads" style="font-weight:700;text-decoration:none">Ads →</a></div>
|
||||
<div style="display:flex;justify-content:space-between;gap:10px"><span>Run a zone on your site</span><a href="/zones" style="font-weight:700;text-decoration:none">Zones →</a></div>
|
||||
<div style="display:flex;justify-content:space-between;gap:10px"><span>Sign-in ad, once a day</span><span class="mono muted" style="font-size:11px">automatic</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261009a"></script>
|
||||
<script src="/assets/wallet.js?v=20261008a"></script>
|
||||
<script src="/assets/cr-shell.js?v=20261012a"></script>
|
||||
<script src="/assets/credits-screen.js?v=20261007a"></script>
|
||||
</body>
|
||||
</html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<title>Credits · LinkSpin</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/cr.css?v=20261012a">
|
||||
<style>
|
||||
.body{padding:16px 24px;display:grid;gap:16px}
|
||||
.two{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:16px;align-items:start}
|
||||
.pkgs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
|
||||
.pk{border:1px solid var(--line);border-radius:8px;padding:12px 12px 10px;background:#FFF;display:flex;flex-direction:column;gap:4px;cursor:pointer;text-align:left;font:inherit;color:inherit;min-height:44px;box-shadow:var(--sh)}
|
||||
.pk:hover{border-color:var(--accent)}
|
||||
.pk.on{border-color:var(--sig);box-shadow:0 0 0 3px rgba(255,106,26,.18);background:linear-gradient(180deg,#FFFFFF,var(--hi-row))}
|
||||
.pk .k{font:700 10px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
|
||||
.pk.on .k{color:var(--sig-2)}
|
||||
.pk .price{font-family:var(--display);font-weight:700;font-size:28px;line-height:1;letter-spacing:.02em}
|
||||
.pk.on .price{color:var(--accent-hi)}
|
||||
.pk .cr{font-size:12px;color:var(--ink-2)}
|
||||
.pk .tag{align-self:flex-start;margin-top:2px}
|
||||
.row{display:flex;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid var(--line);font-size:13px}
|
||||
.row:last-child{border-bottom:0}
|
||||
.buys .hd,.buys .rw{grid-template-columns:150px 110px 130px minmax(0,1fr)}
|
||||
.acts{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
|
||||
@media (max-width:900px){.two{grid-template-columns:1fr}.pkgs{grid-template-columns:repeat(2,minmax(0,1fr))}.buys .hd{display:none}.buys .rw{grid-template-columns:1fr 1fr}.body{padding:12px 16px}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="body">
|
||||
<div class="tiles" id="tiles"></div>
|
||||
<div class="two">
|
||||
<div style="display:grid;gap:16px;align-content:start">
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3>Buy a package</h3><span class="meta" id="buyMeta">priced in dollars · settled in POL at the live rate · one transaction</span></div>
|
||||
<div style="padding:14px 16px 16px;display:grid;gap:14px">
|
||||
<div class="pkgs" id="pkgs"><div class="muted">loading packages…</div></div>
|
||||
<div class="acts">
|
||||
<span class="led"><span style="font-size:10px;letter-spacing:.1em;text-transform:uppercase">you pay</span><b id="payPol">·</b><span id="payUsd"></span></span>
|
||||
<span class="mono muted" style="font-size:11px" id="rateLine"></span>
|
||||
</div>
|
||||
<div class="acts" id="buyActs">
|
||||
<button class="btn pri" type="button" id="buyBtn" disabled>Connect a wallet to buy</button>
|
||||
<button class="btn" type="button" id="cardBtn">Buy POL with a card</button>
|
||||
<span class="muted" style="font-size:12px">SafePal recommended. MetaMask, Phantom and WalletConnect wallets also work.</span>
|
||||
</div>
|
||||
<div id="holdBox" class="warn" style="font-size:13px" hidden></div>
|
||||
<p class="ink2" style="margin:0;font-size:12.5px;line-height:1.5" id="sponsorLine">Loading your sponsor…</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tbl buys">
|
||||
<div class="ph"><h3>Your purchases</h3><span class="meta" id="buysMeta">every row links to the transaction</span></div>
|
||||
<div class="hd"><span>When</span><span>Package</span><span>Paid</span><span>Transaction</span></div>
|
||||
<div id="buyRows"></div>
|
||||
<div class="ft">credits appear in Ads the moment the transaction settles · nothing is held by the site</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:grid;gap:16px;align-content:start">
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3 id="goesTitle">Where it goes</h3><span class="meta">same transaction</span></div>
|
||||
<div style="padding:10px 16px 14px" id="goesRows"></div>
|
||||
</div>
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3>Your wallet</h3><span class="meta" id="walletMeta"></span></div>
|
||||
<div style="padding:12px 16px 14px;display:grid;gap:10px" id="walletBox"></div>
|
||||
</div>
|
||||
<div class="panel" style="padding:0">
|
||||
<div class="ph"><h3>Earn instead</h3><span class="meta">free credits</span></div>
|
||||
<div style="padding:12px 16px 14px;display:grid;gap:8px;font-size:13px" class="ink2">
|
||||
<div style="display:flex;justify-content:space-between;gap:10px"><span>View 5 ads, claim 5 credits</span><a href="/ads" style="font-weight:700;text-decoration:none">Ads →</a></div>
|
||||
<div style="display:flex;justify-content:space-between;gap:10px"><span>Run a zone on your site</span><a href="/zones" style="font-weight:700;text-decoration:none">Zones →</a></div>
|
||||
<div style="display:flex;justify-content:space-between;gap:10px"><span>Sign-in ad, once a day</span><span class="mono muted" style="font-size:11px">automatic</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261009a"></script>
|
||||
<script src="/assets/wallet.js?v=20261008a"></script>
|
||||
<script src="/assets/cr-shell.js?v=20261012a"></script>
|
||||
<script src="/assets/credits-screen.js?v=20261015a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1018
-1018
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user