My line: POL earned from each person; wallet picker features non-Trust wallets first

- /api/my/line sums TierPaid events per buyer for the signed-in member; the
  downline rows show "+X POL" (what that person has paid you so far).
- AppKit featuredWalletIds: MetaMask, Phantom, SafePal, Coinbase first; Trust
  Wallet stays available under All wallets.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-09 07:47:41 -05:00
parent 9608d07544
commit c7018f6258
6 changed files with 33 additions and 8 deletions
+12 -1
View File
@@ -872,11 +872,22 @@ const server = http.createServer(async (req, res) => {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
const levels = await accounts.downline(s.email, 3);
// what each person has paid THIS member so far: sum of TierPaid events where
// this member is the recipient and that person is the buyer (all indexed events)
const myId = await auth.refreshMemberId(s);
const earnedBy = {};
if (myId) {
for (const ev of chain.recentEvents(1e9)) {
if (ev.type === 'TierPaid' && ev.recipientId === myId && ev.buyerId)
earnedBy[ev.buyerId] = (BigInt(earnedBy[ev.buyerId] || '0') + BigInt(ev.amountWei)).toString();
}
}
const out = levels.map(L => ({ level: L.level, members: L.members.map(m => ({
memberId: m.memberId || 0,
name: m.username ? '@' + m.username : m.memberId ? 'member #' + m.memberId : 'member',
email: L.level === 1 ? m.email : null, // directs only
joined: m.created })) }));
joined: m.created,
earnedWei: (m.memberId && earnedBy[m.memberId]) || '0' })) }));
return json(res, 200, { levels: out, counts: out.map(L => L.members.length) });
}
// -- broadcast a message to your downline (1/day), on-site inbox + email