Stack POL: Viral Banner Blitz program (Marty 2026-11-15 standing rule: every rebuilt network site joins Stack POL when it goes live)
- programs.js: 'vbb' entry (slug viral-banner-blitz, pop-art pink #ff2d87, Banner loop), join via the LinkSpin network link nwvbb?src=stackpol&s1=<member>; facts from the VBB app and VBBShop contract only - /earn/viral-banner-blitz + sitemap entry (automatic from the registry); card image public/img/vbb.jpg (VBB og image, 800x420); also adds the missing public/img/dlb.jpg (DLB card image was a 404) - server.js: per-program button verb (Join for the banner sites, not Play) and WebApplication JSON-LD for them; home description no longer calls every program a game - layout.js: Pro personalization also swaps s1=martbost on LinkSpin network links and ?ref=martbost on downlinebanners.com / viralbannerblitz.com links - tools/indexer.py: VBB member payouts read-only from Polygon (VBBShop Paid role 0 sponsor shares + Claimed, eth_getLogs from the deploy block, cache vbb-chain.json) plus weekly prize transfers from VBB prizes.json, each checked on chain (from the prize wallet, to the winner, succeeded); contract, prize, company and keeper wallets excluded. Decoder checked against the Downline Banners contract (same Paid signature): 70 logs, role-0 total matches its chain index exactly - README: sources + the standing rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
stackpol.com: every POL payout across the network, stacked. Live app since 2026-11-09 (replaced the Oct 1 placeholder in the same Coolify slot k6p591wzomylttvsva3e6w7i).
|
||||
|
||||
- server.js (Node 20, no dependencies): home with live network totals, /programs, /earn/<slug> per program, /ledger (?p=<key>), opt-in member stacks at /<username>, /blog (+ /blog/<slug>, /blog/tag/<t>, /blog/feed.xml), /sitemap.xml, /robots.txt, /api/totals. Full SEO head on every page (layout.js): canonical, robots, Open Graph, Twitter card, JSON-LD (WebSite, Organization, FAQPage, BlogPosting, Breadcrumb, ItemList, VideoGame/WebApplication, ProfilePage).
|
||||
- Data: tools/indexer.py runs on core every 5 min (/etc/cron.d/stackpol-indexer, copy in /root/stackpol-indexer) and POSTs a snapshot to /api/ingest (Bearer STACK_INGEST_KEY, key file /root/.stackpol-ingest-key). Sources: each game's payout file, IAP + LinkSpin chain-index TierPaid events, wallet->username from IAP accounts/positions and LinkSpin accounts. Members are named only when opted in (/root/stackpol-indexer/optin.txt + IAP stack-optin.json).
|
||||
- Data: tools/indexer.py runs on core every 5 min (/etc/cron.d/stackpol-indexer, copy in /root/stackpol-indexer) and POSTs a snapshot to /api/ingest (Bearer STACK_INGEST_KEY, key file /root/.stackpol-ingest-key). Sources: each game's payout file, IAP + LinkSpin chain-index TierPaid events, Downline Banners chain-index Paid events (sponsor + line), Viral Banner Blitz VBBShop Paid role 0 + Claimed logs read from Polygon (scan cache /root/stackpol-indexer/vbb-chain.json) and on-chain-checked weekly prize transfers from VBB prizes.json, Earners Corner + PassiveDrip payout ledgers, wallet->username from IAP accounts/positions and LinkSpin accounts. Members are named only when opted in (/root/stackpol-indexer/optin.txt + IAP stack-optin.json).
|
||||
- Blog: content/blog/<slug>.json, one file per post (title, seoTitle, excerpt, body HTML, cover, tags, publishedAt, updated, faq[]). Same engine as InstantAdPay/LinkSpin blog.js, ported to file storage. Future-dated posts stay hidden until their time. Generators in tools/write_posts_*.py.
|
||||
- programs.js: program registry (keys match the indexer); game blurbs are InstantAdPay's own.
|
||||
- mockup/: the Oct design mockup (artifact https://claude.ai/artifact/1mN4dCYUcbw7EHicCdejM3).
|
||||
- Standing rule (Marty 2026-11-15): every rebuilt network site is added here when it goes live: a programs.js entry, its /earn/<slug> page (automatic from the entry, plus public/img/<key>.jpg 800x420) and an indexer source for its member payouts (house/company wallets excluded). Next: ViralAdBlitz, DownlineHydra, 5xYourTeam.
|
||||
|
||||
@@ -146,7 +146,8 @@ function personalize(html, who, st) {
|
||||
if (/^\/(earn|blog|programs|ledger)(\/|\?|$)/.test(h) && !/\/blog\/feed\.xml/.test(h)) return 'href="' + h + (h.includes('?') ? '&' : '?') + 'ref=' + who + '"';
|
||||
if (h === '/') return 'href="/' + who + '"';
|
||||
if (/^https:\/\/(instantadpay\.com|linkspin\.app)\/?$/.test(h)) return 'href="' + h.replace(/\/?$/, '/join/' + who) + '"';
|
||||
if (/^https:\/\/(instantadpay\.com|linkspin\.app)\//.test(h)) return 'href="' + h.replace(/\/join\/martbost\b/, '/join/' + who).replace(/([?&](?:amp;)?ref=)martbost\b/, '$1' + who) + '"';
|
||||
if (/^https:\/\/(instantadpay\.com|linkspin\.app)\//.test(h)) return 'href="' + h.replace(/\/join\/martbost\b/, '/join/' + who).replace(/([?&](?:amp;)?ref=)martbost\b/, '$1' + who).replace(/([?&](?:amp;)?s1=)martbost\b/, '$1' + who) + '"'; // s1 = the member on a LinkSpin network link (nwvbb, 2026-11-15)
|
||||
if (/^https:\/\/(downlinebanners\.com|viralbannerblitz\.com)\//.test(h)) return 'href="' + h.replace(/([?&](?:amp;)?ref=)martbost\b/, '$1' + who) + '"';
|
||||
return m;
|
||||
});
|
||||
}
|
||||
|
||||
+7
-1
@@ -2,6 +2,7 @@
|
||||
// InstantAdPay's own game descriptions (onchain-ad-membership/site server.js GAMES), so this site never invents how a game pays.
|
||||
// join(u): the member's own referral link; the network pages use the site owner's (martbost).
|
||||
'use strict';
|
||||
const { tracked } = require('./netsites');
|
||||
const g = slug => u => 'https://instantadpay.com/g/' + slug + '?ref=' + encodeURIComponent(u);
|
||||
const PROGRAMS = [
|
||||
{ k: 'iap', slug: 'instantadpay', n: 'InstantAdPay', c: '#2dd4bf', kind: 'Ad platform', site: 'https://instantadpay.com', join: u => 'https://instantadpay.com/join/' + encodeURIComponent(u),
|
||||
@@ -10,9 +11,14 @@ const PROGRAMS = [
|
||||
{ k: 'ls', slug: 'linkspin', n: 'LinkSpin', c: '#3b82f6', kind: 'Link tools', site: 'https://linkspin.app', join: u => 'https://linkspin.app/join/' + encodeURIComponent(u),
|
||||
d: 'Free link tools: spin links that rotate your traffic, bridge pages built from any offer link, banner spins and ad zones. Package sales pay the sponsor line in POL in the same transaction.',
|
||||
how: 'Payouts here are the referral payments the LinkSpin smart contract sends up the sponsor line when a package sells, in the same transaction as the purchase.' },
|
||||
{ k: 'dlb', slug: 'downline-banners', n: 'Downline Banners', c: '#c6f432', kind: 'Banner board', site: 'https://downlinebanners.com', join: u => 'https://downlinebanners.com/?ref=' + encodeURIComponent(u),
|
||||
{ k: 'dlb', slug: 'downline-banners', n: 'Downline Banners', c: '#c6f432', kind: 'Banner board', verb: 'Join', app: true, site: 'https://downlinebanners.com', join: u => 'https://downlinebanners.com/?ref=' + encodeURIComponent(u),
|
||||
d: 'The network banner board on Polygon. A $5 spot buys 300 guaranteed views on the board and a place in one line; when later spots sell, the contract pays the 10 spots above them and the buyer\'s sponsor in the same transaction. Nothing is promised.',
|
||||
how: 'Payouts here are the payments the Downline Banners smart contract sends to the buyer\'s sponsor and to the 10 spots above each new spot, in the same transaction as the sale. Company and momentum-fund shares are not counted.' },
|
||||
// Viral Banner Blitz (live 2026-11-14): join through the LinkSpin network link (nwvbb, src=stackpol) so LinkSpin Reports show Stack POL as
|
||||
// the source; it lands on viralbannerblitz.com/?ref=<username>. Facts from the VBB app (how.html, config.js) and the VBBShop contract.
|
||||
{ k: 'vbb', slug: 'viral-banner-blitz', n: 'Viral Banner Blitz', c: '#ff2d87', kind: 'Banner loop', verb: 'Join', app: true, site: 'https://viralbannerblitz.com', join: u => tracked('vbb', 'stackpol', { s1: u }),
|
||||
d: 'A shared loop of 125x125 banners that real visitors move. Network members post one banner free every day they sign in; every 10 verified visitors shift the loop one place, and a banner that rides out has cycled and earns 150 network ad views (advertising, not cash). Weekly leaderboards share a prize pot in POL. Credit packs ($3 for 10, $10 for 40) and a $2 banner look are one-time purchases with SafePal or any other crypto wallet, never a subscription. Nothing is promised.',
|
||||
how: 'Payouts here are the 30% sponsor share the Viral Banner Blitz smart contract pays to the buyer\'s sponsor in the same transaction as each purchase, plus the weekly leaderboard prizes sent in POL from the prize wallet to the winners\' wallets. The prize-wallet and company shares are not counted.' },
|
||||
{ k: 'ph', slug: 'polhunter', n: 'PolHunter', c: '#a3e635', kind: 'Scavenger hunt', site: 'https://polhunter.com', join: g('polhunter'),
|
||||
d: 'Hunt hidden codes on sites across the network. Every find drips POL straight to your wallet.' },
|
||||
{ k: 'ec', slug: 'earners-corner', n: 'Earners Corner', c: '#a78bfa', kind: 'Community forum', site: 'https://earnerscorner.com', join: u => 'https://instantadpay.com/forum/join/' + encodeURIComponent(u),
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
@@ -37,7 +37,7 @@ function card(p, amt, pays, ref, opts) {
|
||||
opts = opts || {};
|
||||
return '<article class="card" style="--c:' + p.c + '"><a class="img" href="/earn/' + p.slug + '"><img src="/img/' + p.k + '.jpg" alt="' + esc(p.n) + ': ' + esc(p.kind) + '" loading="lazy" width="800" height="420"></a><div class="body"><div class="head"><div><div class="nm"><i></i><a href="/earn/' + p.slug + '">' + esc(p.n) + '</a></div><div class="kind">' + esc(p.kind) + '</div></div>'
|
||||
+ '<div class="earned"><b>' + fmt(amt) + '<small>POL</small></b><span>' + fmtInt(pays) + ' ' + (opts.label || 'payments') + '</span></div></div><p>' + esc(p.d) + '</p>'
|
||||
+ '<a class="join" href="' + esc(p.join(ref)) + '" rel="nofollow noopener" target="_blank"><span>' + (p.k === 'iap' || p.k === 'ls' ? 'Join ' + esc(p.n) + ' free' : 'Play ' + esc(p.n) + ' free') + '</span></a></div></article>';
|
||||
+ '<a class="join" href="' + esc(p.join(ref)) + '" rel="nofollow noopener" target="_blank"><span>' + (p.verb || (p.k === 'iap' || p.k === 'ls' ? 'Join' : 'Play')) + ' ' + esc(p.n) + ' free' + '</span></a></div></article>';
|
||||
}
|
||||
function feature(p, ref) {
|
||||
return '<article class="feature"><img src="/img/' + p.k + '.jpg" alt="' + esc(p.n) + '" width="800" height="420"><div class="fb"><span class="ftag">This season</span><h3>' + esc(p.n) + '</h3><p>' + esc(p.d) + '</p><span class="ends">' + esc(p.season.label) + '</span><a class="go" href="' + esc(p.join(ref)) + '" rel="nofollow noopener" target="_blank">Play ' + esc(p.n) + ' free</a></div></article>';
|
||||
@@ -66,7 +66,7 @@ function home() {
|
||||
const ld = [{ '@context': 'https://schema.org', '@type': 'WebSite', name: 'Stack POL', url: SITE + '/', description: 'Every POL payout across the network, stacked in one place.' },
|
||||
{ '@context': 'https://schema.org', '@type': 'Organization', name: 'Stack POL', url: SITE + '/', logo: SITE + '/apple-touch-icon.png', sameAs: ['https://instantadpay.com', 'https://linkspin.app'] },
|
||||
{ '@context': 'https://schema.org', '@type': 'FAQPage', mainEntity: FAQ.map(([q, a]) => ({ '@type': 'Question', name: q, acceptedAnswer: { '@type': 'Answer', text: a } })) }];
|
||||
let h = head({ title: 'Stack POL: Every POL Payout Across the Network, in One Place', desc: 'See every POL payout from InstantAdPay, LinkSpin and ' + (PROGRAMS.length - 2) + ' games that pay on Polygon. ' + fmt(n.pol) + ' POL paid in ' + fmtInt(n.payments) + ' payments so far, each one checkable on Polygonscan.', path: '/', nav: '/', jsonld: ld });
|
||||
let h = head({ title: 'Stack POL: Every POL Payout Across the Network, in One Place', desc: 'See every POL payout from InstantAdPay, LinkSpin and ' + (PROGRAMS.length - 2) + ' more programs that pay on Polygon, games included. ' + fmt(n.pol) + ' POL paid in ' + fmtInt(n.payments) + ' payments so far, each one checkable on Polygonscan.', path: '/', nav: '/', jsonld: ld });
|
||||
h += live();
|
||||
h += '<section class="hero"><div><p class="kick">Paid straight to members\' wallets</p><h1>Every POL the network pays, <span style="color:var(--gold)">stacked in one place</span></h1>';
|
||||
h += '<div class="total"><span class="n" id="tot">' + fmt(n.pol) + '</span><span class="u">POL</span></div><div class="verify"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" aria-hidden="true"><path d="M5 12l5 5 9-10"/></svg>Paid by ' + PROGRAMS.length + ' programs, every payment on Polygon</div>';
|
||||
@@ -94,14 +94,14 @@ function programPage(p, who) { const ref = who || OWNER; // a Pro member's ref (
|
||||
const s = prog(p.k), rows = ((IDX && IDX.progRecent && IDX.progRecent[p.k]) || ((IDX && IDX.recent) || []).filter(r => r.k === p.k)).slice(0, 20);
|
||||
const desc = p.n + ' pays POL on Polygon. ' + fmt(s.pol) + ' POL paid in ' + fmtInt(s.payments) + ' payments to ' + fmtInt(s.wallets) + ' wallets so far. ' + p.d.slice(0, 90);
|
||||
const ld = [{ '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: [{ '@type': 'ListItem', position: 1, name: 'Stack POL', item: SITE + '/' }, { '@type': 'ListItem', position: 2, name: 'Programs', item: SITE + '/programs' }, { '@type': 'ListItem', position: 3, name: p.n, item: SITE + '/earn/' + p.slug }] },
|
||||
p.k === 'iap' || p.k === 'ls' ? { '@context': 'https://schema.org', '@type': 'WebApplication', name: p.n, url: p.site, applicationCategory: 'BusinessApplication', operatingSystem: 'Web', offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' } }
|
||||
p.k === 'iap' || p.k === 'ls' || p.app ? { '@context': 'https://schema.org', '@type': 'WebApplication', name: p.n, url: p.site, applicationCategory: 'BusinessApplication', operatingSystem: 'Web', offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' } }
|
||||
: { '@context': 'https://schema.org', '@type': 'VideoGame', name: p.n, url: p.site, genre: p.kind, gamePlatform: 'Web browser', playMode: 'SinglePlayer', offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' } }];
|
||||
let h = head({ title: p.n + ': How It Pays POL, and What It Has Paid So Far | Stack POL', desc, path: '/earn/' + p.slug, image: '/img/' + p.k + '.jpg', imageAlt: p.n, nav: '/programs', jsonld: ld });
|
||||
h += '<p class="crumb"><a href="/">Stack POL</a> / <a href="/programs">Programs</a> / ' + esc(p.n) + '</p>';
|
||||
h += '<section class="hero" style="padding-top:10px"><div><p class="kick">' + esc(p.kind) + '</p><h1>' + esc(p.n) + '</h1><p class="lead">' + esc(p.d) + '</p>';
|
||||
h += '<div class="total"><span class="n">' + fmt(s.pol) + '</span><span class="u">POL</span></div><div class="stats"><div><b>' + fmtInt(s.payments) + '</b><span>payments</span></div><div><b>' + fmtInt(s.wallets) + '</b><span>wallets paid</span></div>' + (s.last ? '<div><b>' + ago(s.last) + '</b><span>last payout</span></div>' : '') + '</div>';
|
||||
if (p.season) h += '<p style="color:#fb923c;font-weight:700">' + esc(p.season.label) + '</p>';
|
||||
h += '<div class="cta"><a class="btn" href="' + esc(p.join(ref)) + '" rel="nofollow noopener" target="_blank">' + (p.k === 'iap' || p.k === 'ls' ? 'Join ' : 'Play ') + esc(p.n) + ' free</a><a class="btn sec" href="/ledger?p=' + p.k + '">Its payouts on the ledger</a></div></div>';
|
||||
h += '<div class="cta"><a class="btn" href="' + esc(p.join(ref)) + '" rel="nofollow noopener" target="_blank">' + (p.verb || (p.k === 'iap' || p.k === 'ls' ? 'Join' : 'Play')) + ' ' + esc(p.n) + ' free</a><a class="btn sec" href="/ledger?p=' + p.k + '">Its payouts on the ledger</a></div></div>';
|
||||
h += '<aside><img src="/img/' + p.k + '.jpg" alt="' + esc(p.n) + '" width="800" height="420" style="border-radius:18px;border:1px solid var(--line)"></aside></section>';
|
||||
h += '<div class="sec-head"><h2>How ' + esc(p.n) + ' pays</h2></div><p class="lead" style="max-width:72ch">' + esc(p.how || ('Rewards are sent in POL from ' + p.n + '\'s own payout wallet straight to the wallet on your account, on the Polygon network. Every payment is a public transaction you can open on Polygonscan.')) + '</p>';
|
||||
h += '<div class="sec-head"><h2>Latest ' + esc(p.n) + ' payouts</h2><p><a href="/ledger?p=' + p.k + '">All of them</a></p></div>' + tableHead(true) + ledgerRows(rows, true) + '</tbody></table></div>';
|
||||
|
||||
+113
-3
@@ -5,6 +5,9 @@
|
||||
MemberActivated maps a member id to its wallet)
|
||||
- usernames for wallets: IAP accounts + positions (MySQL, via the IAP container) and LinkSpin's accounts.json
|
||||
- opt-in: /root/stackpol-indexer/optin.txt (one username per line) plus IAP's stack-optin.json when present
|
||||
- Viral Banner Blitz (2026-11-15): VBBShop Paid (role 0, sponsor) and Claimed logs read from Polygon with eth_getLogs, plus the
|
||||
weekly prize transfers listed in VBB's prizes.json, each checked on chain (sent by the prize wallet, to that winner, succeeded).
|
||||
The scan position and the checked prize transfers are cached in /root/stackpol-indexer/vbb-chain.json (the only file it writes).
|
||||
It builds one snapshot (network totals, per-program totals, last 7 days, latest 300 payouts, a stack per opted-in member) and
|
||||
POSTs it to https://stackpol.com/api/ingest with the key in /root/.stackpol-ingest-key. Nothing is written anywhere else.
|
||||
The ledger shows each payout's username (Marty 2026-11-09); only opted-in members get a public stack page.
|
||||
@@ -32,9 +35,22 @@ CHAINS = {'iap': 'h8jd2hmt9y3c1gco9ed5nmva-instantadpay-data', 'ls': 'c10c6soppc
|
||||
# (sponsor) or 1 (line level) to anyone but the contract and the two company wallets
|
||||
DLB_VOL = 'gwjsodgtgtc2drdja1ndm0q7*bannerline-data'
|
||||
DLB_HOUSE = {'0x6c77fc0664f58cf17e81966160fc80005a110f9b', '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70', '0x8b7d33849a2c4d92c985be31e46dc564ba901ad2'}
|
||||
# Viral Banner Blitz (2026-11-15): VBBShop on Polygon, read-only. Member payouts = Paid role 0 (the 30% sponsor share pushed in the
|
||||
# purchase tx) + Claimed (a sponsor share whose push failed, pulled later) + the weekly prize transfers from the prize wallet. The
|
||||
# prize-wallet (role 1) and company (role 2) shares, and anything to the contract / prize / company / keeper wallets, are not member payouts.
|
||||
VBB_SHOP = '0x36f6ccc8752dce1c84e06b65f07df30e8a4707d7'
|
||||
VBB_START = 97271183 # deploy block (the app's SHOP_START_BLOCK)
|
||||
VBB_PRIZE = '0x167315726fe50cff97b8f4c91c8c606489397907'
|
||||
VBB_HOUSE = {VBB_SHOP, VBB_PRIZE, '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70', '0x839d97dea43321fcd6dcea1406da4cab6ef29af2'} # + company (Tangem), keeper
|
||||
VBB_RPC = os.environ.get('VBB_RPC', 'https://polygon-bor-rpc.publicnode.com')
|
||||
VBB_TOPICS = {'0x5cd81500d7f34f31cd8d8bd61c8cc1dd873c5ea0a46cd1c00ce014f1781f91d5': 'Paid', # Paid(uint256,address,uint256,uint8)
|
||||
'0xf7a40077ff7a04c7e61f6f26fb13774259ddf1b6bce9ecf26a8276cdd3992683': 'Claimed'} # Claimed(address,address,uint256)
|
||||
VBB_CONFIRM = 30 # blocks behind head
|
||||
VBB_SPAN = 1000 # blocks per eth_getLogs (public RPC limit)
|
||||
VBB_MAX_SPANS = 400 # per run; a long gap catches up over a few runs
|
||||
# The sites keep their data documents in MySQL since 2026-11-13 (docstore.js, table docs). doc() reads one through the app's own
|
||||
# DOCSTORE_URL, inside the database container; falls back to the volume file for an app still on files.
|
||||
APPS = {'iap': 'h8jd2hmt9y3c1gco9ed5nmva', 'ls': 'c10c6soppcsowxsgbrufqb01'}
|
||||
APPS = {'iap': 'h8jd2hmt9y3c1gco9ed5nmva', 'ls': 'c10c6soppcsowxsgbrufqb01', 'vbb': 'y8ywvn6hwl3x1hvs4y7eljbp'}
|
||||
IAP_UUID = 'h8jd2hmt9y3c1gco9ed5nmva'
|
||||
HERE = '/root/stackpol-indexer'
|
||||
URL = 'https://stackpol.com/api/ingest'
|
||||
@@ -62,11 +78,18 @@ def ms(v):
|
||||
return int(v if v > 1e12 else v * 1000)
|
||||
|
||||
|
||||
def doc(app, name, default):
|
||||
def container(uuid):
|
||||
"""the running app container: '<uuid>-...' (plain apps) or '<service>-<uuid>-...' (compose apps like VBB)"""
|
||||
c = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'], capture_output=True, text=True).stdout.split()
|
||||
cont = next((x for x in c if x.startswith(APPS[app])), None)
|
||||
return next((x for x in c if x.startswith(uuid) or ('-' + uuid + '-') in x or x.endswith('-' + uuid)), None)
|
||||
|
||||
|
||||
def doc(app, name, default):
|
||||
cont = container(APPS[app])
|
||||
url = subprocess.run(['docker', 'exec', cont, 'printenv', 'DOCSTORE_URL'], capture_output=True, text=True).stdout.strip() if cont else ''
|
||||
if not url:
|
||||
if app not in CHAINS:
|
||||
return default
|
||||
d = voldir(CHAINS[app])
|
||||
return load(os.path.join(d, name), default) if d else default
|
||||
m = re.match(r'mysql://([^:]+):([^@]+)@([^:/]+)(?::\d+)?/([A-Za-z0-9_]+)', url)
|
||||
@@ -82,6 +105,90 @@ def doc(app, name, default):
|
||||
return default
|
||||
|
||||
|
||||
def rpc(method, params):
|
||||
rq = urllib.request.Request(VBB_RPC, data=json.dumps({'jsonrpc': '2.0', 'id': 1, 'method': method, 'params': params}).encode(),
|
||||
headers={'Content-Type': 'application/json', 'User-Agent': 'stackpol-indexer'})
|
||||
j = json.load(urllib.request.urlopen(rq, timeout=20))
|
||||
if j.get('error'):
|
||||
raise RuntimeError(method + ': ' + str(j['error'].get('message') if isinstance(j['error'], dict) else j['error']))
|
||||
return j.get('result')
|
||||
|
||||
|
||||
def vbb_rows(dry=False):
|
||||
"""Viral Banner Blitz member payouts, read-only on chain. Returns (rows, note). --dry does not save the cache."""
|
||||
cpath = os.path.join(HERE, 'vbb-chain.json')
|
||||
cache = load(cpath, {}) or {}
|
||||
last = int(cache.get('lastBlock') or VBB_START - 1)
|
||||
logs = cache.get('logs') or [] # every Paid/Claimed log seen (all roles), so the counting rule can change without a rescan
|
||||
prizes = cache.get('prizes') or {} # tx -> {to, wei, ts, ok}
|
||||
bts = {}
|
||||
|
||||
def btime(n):
|
||||
if n not in bts:
|
||||
b = rpc('eth_getBlockByNumber', [hex(n), False])
|
||||
bts[n] = int(b['timestamp'], 16) if b and b.get('timestamp') else 0
|
||||
return bts[n]
|
||||
note = ''
|
||||
try:
|
||||
head = int(rpc('eth_blockNumber', []), 16) - VBB_CONFIRM
|
||||
seen = {(x['tx'], x['li']) for x in logs}
|
||||
spans = 0
|
||||
while last < head and spans < VBB_MAX_SPANS:
|
||||
frm, to = last + 1, min(head, last + VBB_SPAN)
|
||||
for l in rpc('eth_getLogs', [{'address': VBB_SHOP, 'topics': [list(VBB_TOPICS)], 'fromBlock': hex(frm), 'toBlock': hex(to)}]) or []:
|
||||
if l.get('removed') or str(l.get('address', '')).lower() != VBB_SHOP:
|
||||
continue
|
||||
kind, t, data = VBB_TOPICS.get(l['topics'][0]), l['topics'], l.get('data') or '0x'
|
||||
key = (l['transactionHash'].lower(), int(l['logIndex'], 16))
|
||||
if not kind or key in seen:
|
||||
continue
|
||||
n = int(l['blockNumber'], 16)
|
||||
if kind == 'Paid':
|
||||
x = {'ev': 'Paid', 'to': '0x' + t[2][-40:].lower(), 'wei': str(int(data[2:66], 16)), 'role': int(data[66:130], 16)}
|
||||
else:
|
||||
x = {'ev': 'Claimed', 'who': '0x' + t[1][-40:].lower(), 'to': '0x' + t[2][-40:].lower(), 'wei': str(int(data[2:66], 16))}
|
||||
x.update({'tx': key[0], 'li': key[1], 'block': n, 'ts': btime(n)})
|
||||
logs.append(x)
|
||||
seen.add(key)
|
||||
last = to
|
||||
spans += 1
|
||||
if last < head:
|
||||
note = 'catching up, %d blocks to go' % (head - last)
|
||||
except Exception as e:
|
||||
note = 'chain read failed (kept the cached logs): %s' % e
|
||||
# weekly prizes: the transfers VBB's prize payer recorded as confirmed, each checked once on chain
|
||||
try:
|
||||
pz = doc('vbb', 'prizes.json', {}) or {}
|
||||
for wk in (pz.get('weeks') or {}).values():
|
||||
for t in wk.get('transfers') or []:
|
||||
tx = str(t.get('tx') or '').lower()
|
||||
if not tx or tx in prizes or t.get('status') != 'confirmed':
|
||||
continue
|
||||
tr, rc = rpc('eth_getTransactionByHash', [tx]), rpc('eth_getTransactionReceipt', [tx])
|
||||
if not tr or not rc:
|
||||
continue
|
||||
ok = rc.get('status') == '0x1' and str(tr.get('from', '')).lower() == VBB_PRIZE and str(tr.get('to', '')).lower() == str(t.get('address', '')).lower()
|
||||
prizes[tx] = {'to': str(tr.get('to', '')).lower(), 'wei': str(int(tr.get('value') or '0x0', 16)), 'ts': btime(int(rc['blockNumber'], 16)), 'ok': ok}
|
||||
except Exception as e:
|
||||
note = (note + '; ' if note else '') + 'prizes unavailable: %s' % e
|
||||
if not dry:
|
||||
tmp = cpath + '.tmp'
|
||||
with open(tmp, 'w', encoding='utf-8', newline='\n') as f:
|
||||
json.dump({'lastBlock': last, 'logs': logs, 'prizes': prizes, 'at': int(time.time())}, f)
|
||||
os.replace(tmp, cpath)
|
||||
rows = []
|
||||
for x in logs:
|
||||
member = (x['ev'] == 'Paid' and x.get('role') == 0) or (x['ev'] == 'Claimed' and x.get('who') not in VBB_HOUSE)
|
||||
if member and x['to'] not in VBB_HOUSE and int(x['wei']) > 0:
|
||||
rows.append({'k': 'vbb', 'pol': int(x['wei']) / 1e18, 'tx': x['tx'], 'ts': ms(x['ts']), 'w': x['to'], 'gu': ''})
|
||||
for tx, x in prizes.items():
|
||||
if x.get('ok') and x['to'] not in VBB_HOUSE and int(x['wei']) > 0:
|
||||
rows.append({'k': 'vbb', 'pol': int(x['wei']) / 1e18, 'tx': tx, 'ts': ms(x['ts']), 'w': x['to'], 'gu': ''})
|
||||
allwei = sum(int(x['wei']) for x in logs if x['ev'] == 'Paid')
|
||||
return rows, 'vbb: scanned to block %d, %d contract logs (%.4f POL in all Paid events), %d prize transfers checked, %d member payouts %.4f POL%s' % (
|
||||
last, len(logs), allwei / 1e18, len(prizes), len(rows), sum(r['pol'] for r in rows), ('; ' + note) if note else '')
|
||||
|
||||
|
||||
def iap_wallet_users():
|
||||
"""{address_lower: username} from IAP accounts + positions, via the IAP container (its DATABASE_URL never leaves it)."""
|
||||
c = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'], capture_output=True, text=True).stdout.split()
|
||||
@@ -161,6 +268,9 @@ def main():
|
||||
continue
|
||||
if pol > 0:
|
||||
rows.append({'k': 'dlb', 'pol': pol, 'tx': e['tx'], 'ts': ms(e.get('ts') or 0), 'w': str(e.get('to') or '').lower(), 'gu': ''})
|
||||
vr, vnote = vbb_rows(dry)
|
||||
rows += vr
|
||||
print(vnote)
|
||||
# wallet -> username
|
||||
wu = iap_wallet_users()
|
||||
lsd = voldir(CHAINS['ls'])
|
||||
|
||||
Reference in New Issue
Block a user