edaf98c8f6
Watershed look from the approved mockup (hero, topo pattern, icons). Network sign-in through the hub, hub membership, activity ping. Reshare links per member per ad with branch/step tracking; family-tree dashboard (branch, step, reshares, views, clicks, sign-ups, Boosts). Verified views earn ad credits for the branch's resharer (L3). L2 sign-up pipeline (hub-new, confirmed email, not self device/IP, throwaway block, daily cap, fraud score) with keeper-signed reward vouchers and a pending-rewards ledger; payouts OFF (REWARD_PAYOUTS). L1 Boosts through VASShop with signed orders naming the sponsor line and the resharer. Trust pack, chatbot, promo kit, PolHunter embed. All numbers are PROPOSALS until Marty sets them. qa/e2e.mjs 59/59 on a local anvil chain, chatbot test 108/108. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
5.9 KiB
JavaScript
76 lines
5.9 KiB
JavaScript
// All runtime config comes from env (Coolify sets these). Read once.
|
|
// ViralAdSource (viraladsource.com rebuild, Marty approved 2026-11-16: "that looks good. Let's go with it."). "Every ad has a source.
|
|
// Watch yours travel." A network member posts one free text ad; anyone reshares it with their own unique reshare link; every
|
|
// reshare is a branch of the ad's family tree. Rewards are for verified RESULTS only, never a bare share:
|
|
// L1 a Boost bought through a branch: the resharer's cut is paid by VASShop in the same transaction (server-signed order).
|
|
// L2 a verified brand-new network member through a branch: a small POL reward from the contract's reward pot, after real-time
|
|
// checks (hub-new, confirmed email, not the resharer's device/IP/wallet, no throwaway email, daily cap, fraud score).
|
|
// PAYOUTS ARE OFF (REWARD_PAYOUTS=1 turns the relay on) until Marty confirms the amounts.
|
|
// L3 verified views through a branch: ad credits for the resharer, spent on their own ad. Ad credits buy advertising, not income.
|
|
// Every number below marked PROPOSAL is Claude's proposal (2026-11-16); Marty has not set them.
|
|
const path = require('path');
|
|
|
|
let cfg = null;
|
|
function get() {
|
|
if (cfg) return cfg;
|
|
const e = process.env;
|
|
const num = (v, d, min, max) => { const n = Number(v); return Number.isFinite(n) && v !== '' && v != null ? Math.min(max, Math.max(min, n)) : d; };
|
|
const int = (v, d, min, max) => Math.round(num(v, d, min, max));
|
|
const addr = v => /^0x[0-9a-fA-F]{40}$/.test(String(v || '').trim()) ? require('ethers').getAddress(String(v).trim().toLowerCase()) : '';
|
|
let tiers = [];
|
|
try { tiers = JSON.parse(e.REWARD_TIERS || '[]'); } catch (x) { tiers = []; }
|
|
if (!Array.isArray(tiers) || !tiers.length) tiers = [{ every: 25, cents: 250, lockDays: 14 }]; // PROPOSAL: each 25th verified sign-up from one resharer = a $2.50 bonus, withdrawable after 14 days
|
|
cfg = {
|
|
port: Number(e.PORT || 3000),
|
|
isProd: e.NODE_ENV === 'production',
|
|
site: e.SITE_HOST || 'viraladsource.com',
|
|
siteName: 'ViralAdSource',
|
|
siteId: 'viraladsource', // hub site id, network sign-in audience, netsites id
|
|
staging: e.STAGING === '1', // staging only: the admin "mark test member" switch, no ad zones
|
|
dataDir: e.DATA_DIR || path.join(__dirname, 'data'),
|
|
chainId: Number(e.CHAIN_ID || 137),
|
|
chainName: e.CHAIN_NAME || 'Polygon',
|
|
publicRpc: e.PUBLIC_RPC || 'https://polygon-bor-rpc.publicnode.com',
|
|
walletConnectProjectId: (e.WALLETCONNECT_PROJECT_ID || '').trim(),
|
|
// ---- Boost (PROPOSAL $5). The contract's SKU holds the real price; this is display copy and must match it.
|
|
// A Boost puts the ad at the top of the reshare board for `days` days per unit. One-time, never a subscription.
|
|
boost: { sku: int(e.BOOST_SKU, 1, 1, 1000), usd: num(e.BOOST_USD, 5, 0.01, 1000), days: int(e.BOOST_DAYS, 7, 1, 365), maxQty: 10 },
|
|
// VASShop split (PROPOSAL; owner-settable on the contract, read live from it when the contract is set): basis points
|
|
split: { resharerBps: int(e.SPLIT_RESHARER_BPS, 2000, 0, 9000), potBps: int(e.SPLIT_POT_BPS, 1000, 0, 9000), levelBps: String(e.SPLIT_LEVEL_BPS || '500,500,500,500,500').split(',').map(x => int(x, 0, 0, 9000)).slice(0, 5), maxDepth: 20 },
|
|
// ---- L2 sign-up rewards (PROPOSAL $0.25, 10 a day per resharer). Payouts OFF unless REWARD_PAYOUTS=1.
|
|
reward: { cents: int(e.REWARD_CENTS, 25, 1, 10000), dailyCap: int(e.REWARD_DAILY_CAP, 10, 0, 1000), tiers,
|
|
payouts: e.REWARD_PAYOUTS === '1', fraudHold: int(e.FRAUD_HOLD, 50, 1, 100), voucherDays: int(e.REWARD_VOUCHER_DAYS, 30, 1, 365),
|
|
joinWindowHours: int(e.JOIN_WINDOW_HOURS, 72, 1, 720) },
|
|
hubJoin: e.HUB_JOIN === '1', // a confirmed sign-up is written to the hub (join-all). OFF on staging: a dry check instead
|
|
mail: { from: String(e.MAIL_FROM || 'ViralAdSource <noreply@viraladsource.com>'), url: String(e.MAIL_URL || '').trim() }, // MAIL_URL unset = no mail sent (staging)
|
|
// ---- L3 ad credits (PROPOSAL: 10 credits per 100 verified views through a branch; 1 credit = 1 verified view of your own ad)
|
|
credits: { per: int(e.CREDITS_PER, 10, 1, 1000), views: int(e.CREDITS_VIEWS, 100, 1, 100000), slots: int(e.CREDIT_SLOTS, 2, 0, 10) },
|
|
// verified visitors (the VBB / ViralAdBlitz rules)
|
|
visitSeconds: int(e.VISIT_SECONDS, 6, 2, 60),
|
|
visitWindowHours: 24,
|
|
perIpDay: int(e.VISITS_PER_IP_DAY, 3, 1, 100),
|
|
boardSize: int(e.BOARD_SIZE, 12, 3, 50),
|
|
viaDays: int(e.VIA_DAYS, 30, 1, 365), // how long a reshare link's tag stays on a visitor (last touch)
|
|
maxStep: int(e.MAX_STEP, 50, 2, 500), // the deepest reshare step kept
|
|
ad: { headline: 60, line: 90 },
|
|
linkProbe: e.LINK_PROBE !== '0',
|
|
explorer: String(e.EXPLORER || (Number(e.CHAIN_ID || 137) === 137 ? 'https://polygonscan.com' : '')).replace(/\/+$/, ''),
|
|
// VASShop (../contracts). KEEPER_KEY / RELAY_KEY are read by shop.js only, never kept here.
|
|
contractAddress: addr(e.CONTRACT_ADDRESS),
|
|
companyWallet: addr(e.COMPANY_WALLET) || '0x7627Fc78876948AC9d95C1C9eB061E7D6d647b70', // Tangem (immutable in VASShop)
|
|
chainRpc: String(e.CHAIN_RPC || '').trim(),
|
|
shopStartBlock: int(e.SHOP_START_BLOCK, 0, 0, 1e12),
|
|
shopConfirmations: int(e.SHOP_CONFIRMATIONS, 10, 0, 1000),
|
|
shopPollMs: int(e.SHOP_POLL_MS, 30000, 200, 3600000),
|
|
voucherSeconds: int(e.VOUCHER_SECONDS, 1800, 60, 86400),
|
|
iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''),
|
|
lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''),
|
|
joinUrl: String(e.JOIN_URL || 'https://instantadpay.com/join/{ref}'),
|
|
networkLookupUrl: e.NETWORK_LOOKUP_URL !== undefined ? String(e.NETWORK_LOOKUP_URL).trim()
|
|
: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '') + '/api/network/member'
|
|
};
|
|
return cfg;
|
|
}
|
|
|
|
module.exports = { get, reset: () => { cfg = null; } };
|