Skip to content

feat(wm): /wm profile — KBVE username + wallet balance (read-only, ephemeral) - #14312

Open
h0lybyte wants to merge 2 commits into
devfrom
feat/wm-profile
Open

feat(wm): /wm profile — KBVE username + wallet balance (read-only, ephemeral)#14312
h0lybyte wants to merge 2 commits into
devfrom
feat/wm-profile

Conversation

@h0lybyte

Copy link
Copy Markdown
Member

What

New /wm profile — an ephemeral embed showing the invoking Discord user's linked KBVE username, credits (USD-pegged) and khash balance. Read-only preview; spending is a later phase. First step of the profile/credits-on-Discord prep.

Pieces

  • Migration public.proxy_discord_profile(p_discord_id text) — one service-role PostgREST RPC that joins tracker.find_claim_identity_by_discord_id (Discord→KBVE link) + wallet.service_user_balance (credits/khash), so the bot reads profile+balance in a single HTTP call while both source schemas stay private. linked=false + zero balances for unlinked snowflakes.
  • f/shared/profile.ts — PostgREST read with a best-effort short-TTL (60s) Valkey cache in front. Graceful: absent client / miss / any error falls through to the DB, so the cache is never load-bearing. Uses Bun's native redis client (zero-dep).
  • f/discordsh/profile.ts — ephemeral embed (username, credits $ + raw, khash). Unlinked users get a "sign in with Discord at kbve.com" prompt.
  • Bot — honors a top-level ephemeral: true in a script result → keeps the reply invoker-only and drops the public reroll button. Extends the embed contract without touching existing commands.

Privacy

Balances are ephemeral (only the invoker sees them) — the opposite of the now-public reroll embeds. That's why the contract flag exists.

⚠️ Prereqs to go live (coordinated across 3 pipelines)

  1. Migration applied via ci-dbmate before the script runs (else RPC 404).
  2. Windmill workspace resources (one-time ops step — can't be done from the repo):
    • f/discordsh/kbve_supabase resource → { url, service_key } (service_role key).
    • f/discordsh/valkey_url variable → Valkey connection URL (optional; blank = cache disabled, still works).
  3. Bot redeploy (0.1.28) for the ephemeral-flag contract.
    Scripts sync via windmill-sync on merge to main; order: migration → resources → scripts/bot.

Verified

  • cargo build clean; both TS scripts bun build clean.
  • Balance read path exercised against the real schema shape (proxy joins verified against the existing function signatures).

Follow-up (tracked): spending (debit RPCs, /wm spend), optional footer balance on other embeds, confirm Bun redis client version in the Windmill runtime.

h0lybyte added 2 commits July 19, 2026 03:10
Adds an ephemeral /wm profile command showing the invoking Discord user's
linked KBVE username, credits (USD-pegged) and khash balance.

- Migration public.proxy_discord_profile(discord_id): one service-role
  PostgREST RPC joining tracker.find_claim_identity_by_discord_id +
  wallet.service_user_balance, keeping both schemas private.
- f/shared/profile.ts core: PostgREST read with a best-effort short-TTL
  Valkey cache in front (graceful — absent/failed cache falls through to DB).
- f/discordsh/profile.ts surface: ephemeral embed; unlinked users get a
  link-your-account prompt. Read-only — spending is a later phase.
- Bot honors a top-level ephemeral flag in the result → private, no reroll.

Bump 0.1.28. Prereqs to go live in commit body / PR.
Discord locks response visibility at defer time, so the script's
ephemeral flag alone rendered the wallet embed publicly. Known-private
command leaves now defer_ephemeral before the script runs.

creditsToUsd divided by 100_000; peg is $1 = 1,000,000 credits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant