Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
Remove completed monetization task files, update monetization/oauth/widgets tests
nirholas9d8f031b61fb
diff --git a/tasks/monetization-feature/18-backend-revenue-sharing.md b/tasks/monetization-feature/18-backend-revenue-sharing.mddeleted file mode 100644index 08b7744aa..000000000--- a/tasks/monetization-feature/18-backend-revenue-sharing.md+++ /dev/null@@ -1,68 +0,0 @@-----status: not-started-----# Prompt 18: Backend Revenue Sharing--**Status:** Not Started--## Objective-Implement a simple revenue sharing model in the backend where the platform takes a small percentage fee from each skill sale.--## Explanation-To create a sustainable business model, the platform needs to generate revenue. A common approach is to take a small commission on transactions occurring in the marketplace. This task modifies the transaction creation logic to include a platform fee.--## Instructions-1. **Establish a platform wallet address.** Store this securely in your backend environment variables (e.g., `PLATFORM_WALLET_ADDRESS`).-2. **Define the platform fee percentage.** Store this as a constant or environment variable (e.g., `PLATFORM_FEE_PERCENT = 0.05` for 5%).-3. **Locate the API endpoint that initiates the purchase transaction (`/api/skills/:skill_id/purchase` from Prompt 5).**-4. **Modify the transaction construction logic:**- - Calculate the payment amount for the creator (`price * (1 - PLATFORM_FEE_PERCENT)`).- - Calculate the platform fee amount (`price * PLATFORM_FEE_PERCENT`).- - Instead of one `SystemProgram.transfer` instruction, the transaction will now have two:- - One transfer from the user to the skill creator's wallet.- - A second transfer from the user to the platform's wallet.-5. **Return the new two-instruction transaction to the client for signing.**--## Code Example (Backend - `initiatePurchase` logic)-```javascript-// ... inside the initiatePurchase function-const priceInfo = ...-const creatorWallet = new PublicKey(creator.wallet_address);-const platformWallet = new PublicKey(process.env.PLATFORM_WALLET_ADDRESS);-const feePercentage = 0.05; // 5%--const creatorAmount = Math.floor(priceInfo.amount * (1 - feePercentage));-const feeAmount = priceInfo.amount - creatorAmount; // Avoid floating point issues--const transaction = new Transaction(...);--// Transfer to creator-transaction.add(SystemProgram.transfer({- fromPubkey: user_wallet,- toPubkey: creatorWallet,- lamports: creatorAmount,-}));--// Transfer to platform-transaction.add(SystemProgram.transfer({- fromPubkey: user_wallet,- toPubkey: platformWallet,- lamports: feeAmount,-}));--// Serialize and return transaction...-```--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/18-backend-revenue-sharing.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/18-terms-of-service-and-privacy-policy.md b/tasks/monetization-feature/18-terms-of-service-and-privacy-policy.mddeleted file mode 100644index 804e98000..000000000--- a/tasks/monetization-feature/18-terms-of-service-and-privacy-policy.md+++ /dev/null@@ -1,54 +0,0 @@-----status: not-started------# Prompt 18: Legal - Terms of Service & Privacy Policy--## Objective-Create and integrate the necessary legal documents, such as a Terms of Service and Privacy Policy, to comply with regulations and define the rules of your platform.--## Explanation-When you handle user data and money, having clear, comprehensive legal documents is non-negotiable. The Terms of Service (ToS) outlines the agreement between the platform and its users, while the Privacy Policy explains how user data is collected, used, and protected. This task is essential for legal compliance and building user trust.--**Disclaimer:** This prompt provides a general guide. You must consult with a qualified legal professional to draft documents appropriate for your specific business and jurisdiction.--## Instructions-1. **Draft the Legal Documents:**- * Work with a lawyer to draft a **Terms of Service**. This should cover:- * User responsibilities.- * Payment terms, creator payout policies, and fees.- * Intellectual property rights for agents and skills.- * Rules for API usage and subscriptions.- * Disclaimers and limitations of liability.- * Draft a **Privacy Policy**. This should cover:- * What data you collect (e.g., email, payment info, IP addresses).- * How you use the data.- * How you share data with third parties (like Stripe).- * User rights regarding their data (e.g., GDPR, CCPA compliance).--2. **Create Static Pages for the Documents:**- * Create two new HTML files in your project: `terms-of-service.html` and `privacy-policy.html`.- * Paste the content of your legal documents into these pages. Format them for readability (e.g., using proper headings and lists).--3. **Link to the Documents:**- * **Footer:** Add links to both the ToS and Privacy Policy in the main site footer so they are accessible from every page.- * **Registration Form:** Add a checkbox to the signup form that says "I agree to the <a href="/terms-of-service.html">Terms of Service</a> and <a href="/privacy-policy.html">Privacy Policy</a>." This checkbox must be required to complete registration.- * **Settings/Profile:** It's also good practice to have links to these documents in the user's account settings area.--4. **Backend Check for Agreement:**- * Your registration API endpoint (`/api/auth/register`) should ideally accept a boolean parameter like `agreedToTerms: true`.- * The API should reject any registration request where this is not `true`. This creates a server-side record of the user's agreement.--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/18-terms-of-service-and-privacy-policy.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/19-creator-analytics.md b/tasks/monetization-feature/19-creator-analytics.mddeleted file mode 100644index 686d79f15..000000000--- a/tasks/monetization-feature/19-creator-analytics.md+++ /dev/null@@ -1,51 +0,0 @@-----status: not-started-----# Prompt 19: Creator Analytics Page--**Status:** Not Started--## Objective-Create a basic analytics page for creators to view their sales and total revenue.--## Explanation-Providing creators with data on their skill performance is crucial for a healthy ecosystem. This task involves creating a new page and API endpoint to display simple metrics like total sales, revenue, and a list of recent transactions.--## Instructions-1. **Backend: Create a new API endpoint `GET /api/creator/analytics`.**- - This endpoint should be authenticated.- - It should query the `skill_purchases` table, filtering for skills created by the logged-in user.- - Calculate aggregate data: `total_sales`, `total_revenue`.- - Retrieve the last 10-20 purchase records (`skill_name`, `purchase_at`, `purchase_amount`).- - Return this data as a JSON object.-2. **Frontend: Create a new page `public/creator-analytics.html`.**-3. **Add a new script `src/creator-analytics.js`.**-4. **On page load, fetch data from the new analytics endpoint.**-5. **Render the data in a user-friendly way:**- - Display "Total Revenue" and "Total Skills Sold" in prominent stat boxes.- - Show a table of "Recent Sales" with details for each transaction.--## Code Example (Backend - SQL Query for Analytics)-```sql-SELECT- COUNT(*) AS total_sales,- SUM(p.purchase_amount) AS total_revenue-FROM skill_purchases p-JOIN skills s ON p.skill_id = s.id-WHERE s.creator_id = $1; -- $1 is the authenticated user's ID-```-This gives creators valuable insight and encourages them to build more high-quality skills.--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/19-creator-analytics.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/19-revenue-events-table.md b/tasks/monetization-feature/19-revenue-events-table.mddeleted file mode 100644index fed0e3727..000000000--- a/tasks/monetization-feature/19-revenue-events-table.md+++ /dev/null@@ -1,148 +0,0 @@-# Prompt 19: Revenue Events API and Table--## Objective-Create an API endpoint to fetch a paginated list of individual revenue events for a user, and display these events in a table on the Revenue Dashboard.--## Explanation-After seeing their high-level stats, creators will want to see the breakdown of their earnings. A transaction history, or "revenue events" list, provides this transparency. We need a paginated API to handle potentially large numbers of events, and a clean table on the frontend to display them.--## Instructions-1. **Create the Backend API Endpoint:**- * Create a new file: `/api/billing/revenue-events.js`.- * This `GET` endpoint must be authenticated and should support cursor-based pagination (`?cursor=...`).- * Query the `agent_revenue_events` table, filtering by the agents owned by the current `user_id`.- * For each event, you should also join `agent_identities` to get the `agent_name`.- * Order the results by `created_at DESC`.- * Return a list of events and a `next_cursor` for the frontend to use for "Load More" functionality. Each event object should include details like date, skill name, agent name, and the net amount earned.--2. **Update the Frontend Dashboard:**- * In `public/dashboard/dashboard.js`, create a new function `loadRevenueEvents`. Call this from within `renderRevenue` after the stats have been loaded.- * This function will fetch data from `/api/billing/revenue-events`.- * Create a rendering function `renderRevenueEventsTable(events)` that generates the HTML for a table.- * The table should have columns for: Date, Agent, Skill, and Net Amount.- * Display the data in the `#revenue-events-table-container` element.- * Implement a "Load More" button that appears if the API response includes a `next_cursor`. Clicking this button should fetch the next page and append the new rows to the table.--## Code Example (Backend - `/api/billing/revenue-events.js`)--```javascript-import { sql } from '../_lib/db.js';-import { getSessionUser } from '../_lib/auth.js';-import { json, wrap, error } from '../_lib/http.js';--const PAGE_SIZE = 20;--export default wrap(async (req, res) => {- const user = await getSessionUser(req);- if (!user) return error(res, 401, 'unauthorized');-- const url = new URL(req.url, 'http://x');- const cursor = url.searchParams.get('cursor');-- const rows = await sql`- SELECT- rev.id,- rev.created_at,- rev.skill,- rev.net_amount,- ai.name AS agent_name- FROM agent_revenue_events rev- JOIN agent_identities ai ON rev.agent_id = ai.id- WHERE ai.user_id = ${user.id}- AND (${cursor}::timestamptz IS NULL OR rev.created_at < ${cursor})- ORDER BY rev.created_at DESC- LIMIT ${PAGE_SIZE + 1}- `;-- const hasMore = rows.length > PAGE_SIZE;- const events = rows.slice(0, PAGE_SIZE);- const nextCursor = hasMore ? events[events.length - 1].created_at.toISOString() : null;-- return json(res, 200, {- events,- next_cursor: nextCursor,- });-});-```--## Code Example (Frontend - `public/dashboard/dashboard.js`)--```javascript-async function renderRevenue(root) {- // ... code to render page shell and stats ...-- // Add a container for the table- root.querySelector('#revenue-events-table-container').innerHTML = `- <div class="panel">- <div class="panel-header"><h2>Transaction History</h2></div>- <div class="panel-body no-pad">- <table id="revenue-events-table">- <thead>- <tr><th>Date</th><th>Agent</th><th>Skill</th><th>Net Earning</th></tr>- </thead>- <tbody></tbody>- </table>- </div>- <div class="panel-footer" id="revenue-load-more-container"></div>- </div>- `;-- loadRevenueEvents(); // Initial load-}--let eventsNextCursor = null;--async function loadRevenueEvents(cursor = null) {- const container = document.getElementById('revenue-load-more-container');- container.innerHTML = cursor ? '<button disabled>Loading...</button>' : '';-- try {- const url = new URL('/api/billing/revenue-events', location.origin);- if (cursor) url.searchParams.set('cursor', cursor);- const res = await fetch(url, { credentials: 'include' });- const { events, next_cursor } = await res.json();-- const tbody = document.querySelector('#revenue-events-table tbody');- if (!cursor && !events.length) {- tbody.innerHTML = '<tr><td colspan="4" style="text-align:center;padding:2rem;">No revenue events yet.</td></tr>';- container.innerHTML = '';- return;- }-- const formatUSDC = (amount) => `$${(Number(amount) / 1e6).toFixed(2)}`;- tbody.insertAdjacentHTML('beforeend', events.map(e => `- <tr>- <td>${new Date(e.created_at).toLocaleDateString()}</td>- <td>${esc(e.agent_name)}</td>- <td>${esc(e.skill)}</td>- <td>${formatUSDC(e.net_amount)}</td>- </tr>- `).join(''));-- eventsNextCursor = next_cursor;- if (next_cursor) {- container.innerHTML = '<button id="rev-load-more">Load More</button>';- document.getElementById('rev-load-more').addEventListener('click', () => loadRevenueEvents(eventsNextCursor));- } else {- container.innerHTML = '';- }-- } catch (e) {- container.innerHTML = `<div class="err">Failed to load history.</div>`;- }-}-```--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/19-revenue-events-table.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/20-analytics-for-creators.md b/tasks/monetization-feature/20-analytics-for-creators.mddeleted file mode 100644index ffdf136e1..000000000--- a/tasks/monetization-feature/20-analytics-for-creators.md+++ /dev/null@@ -1,45 +0,0 @@-----status: not-started------# Prompt 20: Analytics for Creators--**Status:** Not Started--## Objective-Provide creators with analytics on their skill sales, such as page views, conversion rates, and top referrers.--## Explanation-Data helps creators make better decisions. We can provide them with simple analytics to understand how their agent is performing in the marketplace.--## Instructions-- [ ] **Track Events:**- - Create a new table `analytics_events`.- - Log key events: `agent_page_view`, `skill_purchase`, `referral_link_click`.- - Include details like `agent_id`, `user_id`, and other relevant metadata.-- [ ] **Create a new API endpoint, e.g., `GET /api/dashboard/analytics`**.- - This endpoint will query the `analytics_events` table and aggregate the data.- - Calculate metrics like:- - Total views in the last 30 days.- - Number of sales.- - Conversion rate (sales / views).- - Top-performing skills.-- [ ] **Create a new "Analytics" tab in the creator dashboard.**-- [ ] **Display the analytics using simple charts and cards.**- - A line chart for views over time.- - A bar chart for sales per skill.- - A summary card for conversion rate.--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/20-analytics-for-creators.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/20-ui-transaction-history.md b/tasks/monetization-feature/20-ui-transaction-history.mddeleted file mode 100644index f5cff924f..000000000--- a/tasks/monetization-feature/20-ui-transaction-history.md+++ /dev/null@@ -1,57 +0,0 @@-----status: not-started-----# Prompt 20: User Transaction History UI--**Status:** Not Started--## Objective-Create a "Transaction History" page for users to see a list of their past skill purchases.--## Explanation-Users need a way to track their spending and see a record of the skills they've acquired. This adds transparency and helps with user account management.--## Instructions-1. **Backend: Create a new endpoint `GET /api/users/me/purchases`.**- - The endpoint must be authenticated.- - Query the `skill_purchases` table for all records matching the logged-in `user_id`.- - For each record, join with the `skills` and `agents` tables to get their names.- - Return an array of purchase objects.-2. **Frontend: Create a new page `public/purchase-history.html`.**-3. **Create a script `src/purchase-history.js`.**-4. **Fetch data from the new endpoint on page load.**-5. **Render the data as a table or a list.**- - Each row should display: Skill Name, Agent Name it was purchased for, Price, and Purchase Date.- - Include a link to the transaction signature on a block explorer like Solscan or Solana Explorer.--## Code Example (Frontend - Rendering a history row)-```javascript-// purchases is the array from the API-const historyHtml = purchases.map(p => `- <tr>- <td>${p.skill_name}</td>- <td>${p.agent_name}</td>- <td>${(p.purchase_amount / 1e6).toFixed(2)} USDC</td>- <td>${new Date(p.purchased_at).toLocaleDateString()}</td>- <td>- <a href="https://solscan.io/tx/${p.transaction_signature}" target="_blank">View on Solscan</a>- </td>- </tr>-`).join('');--document.getElementById('history-table-body').innerHTML = historyHtml;-```--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/20-ui-transaction-history.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/22-gifting-skills.md b/tasks/monetization-feature/22-gifting-skills.mddeleted file mode 100644index 5f241d6a1..000000000--- a/tasks/monetization-feature/22-gifting-skills.md+++ /dev/null@@ -1,40 +0,0 @@-----status: not-started------# Prompt 22: Gifting Skills--**Status:** Not Started--## Objective-Allow a user to purchase a skill and gift it to another user.--## Explanation-Gifting can be a new acquisition channel. A user might buy a skill for a friend to try out.--## Instructions-- [ ] **Update the purchase flow UI.**- - Add a "Buy as a Gift" checkbox.- - If checked, an input field appears for the recipient's username or wallet address.-- [ ] **Modify the purchase API and logic.**- - The purchase transaction is the same (the buyer pays).- - However, when the purchase is confirmed, the entry in the `user_skill_access` table should be created for the *recipient*, not the buyer.-- [ ] **Send a notification to the recipient.**- - After the purchase, send an on-site notification or an email to the recipient informing them that "User X has gifted you the skill Y!"-- [ ] **Update the purchase history.**- - The buyer's history should indicate that the purchase was a gift and show who it was for.- - The recipient should also see the gifted skill in their list of owned skills.--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/22-gifting-skills.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tasks/monetization-feature/24-subscription-management-ui.md b/tasks/monetization-feature/24-subscription-management-ui.mddeleted file mode 100644index 25839f9a2..000000000--- a/tasks/monetization-feature/24-subscription-management-ui.md+++ /dev/null@@ -1,79 +0,0 @@-----status: not-started------# Prompt 24: Frontend - Subscription Management UI--## Objective-Create a user interface that allows developers to manage their API subscriptions, including upgrading, downgrading, and canceling plans.--## Explanation-A self-service subscription management portal is essential for a smooth developer experience and for reducing customer support load. This UI will typically link out to a secure, pre-built portal hosted by your payment provider (like Stripe), where users can manage their payment methods and subscription status directly.--## Instructions-1. **Backend - Create Stripe Customer Portal Endpoint:**- * Create a new backend API endpoint, e.g., `/api/billing/create-portal-session`.- * This endpoint will use the Stripe Node.js SDK.- * It should authenticate the user to get their `user_id`.- * It will look up the user's `stripe_customer_id` from your `subscriptions` or `users` table.- * It then calls `stripe.billingPortal.sessions.create()` to generate a unique, single-use URL for that customer's portal.- * The endpoint returns this URL to the frontend.--2. **Frontend - Add a "Manage Subscription" Page/Section:**- * On your `api-keys.html` page, or a new `billing.html` page, create a new section called "Subscription Status".- * Display the user's current plan name (e.g., "Developer Plan") and the status (e.g., "Active"). You will get this from your own database via an endpoint.- * Add a prominent button labeled "Manage Billing & Subscription".--3. **Frontend - Implement the Button Logic:**- * In the JavaScript for this page, add a click handler to the "Manage" button.- * When clicked, it should make a `POST` request to your new `/api/billing/create-portal-session` endpoint.- * The API will respond with a JSON object containing the portal URL.- * The frontend should then redirect the user to this URL: `window.location.href = data.url;`.--4. **Configure the Stripe Customer Portal:**- * In your Stripe dashboard, go to the Customer Portal settings.- * Configure which actions you want to allow users to perform (e.g., update payment methods, view invoice history, change plans, cancel subscriptions).- * Set the redirect URL to bring users back to your application after they are done.--## Backend Endpoint Example--```javascript-// POST /api/billing/create-portal-session-const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);--export default wrap(async (req, res) => {- const user = await getSessionUser(req);- if (!user) return error(res, 401);-- // 1. Fetch the user's Stripe Customer ID from your database- const [sub] = await sql`- SELECT stripe_customer_id FROM subscriptions WHERE user_id = ${user.id} AND status = 'active'- `;- if (!sub || !sub.stripe_customer_id) {- return error(res, 404, 'not_found', 'No active subscription found.');- }-- // 2. Create the portal session- const portalSession = await stripe.billingPortal.sessions.create({- customer: sub.stripe_customer_id,- return_url: `${process.env.APP_ORIGIN}/api-keys`, // URL to return to- });-- // 3. Return the URL for redirect- return json(res, 200, { url: portalSession.url });-});-```--<!-- AUTO:self-delete-on-complete -->-------## ✅ On completion — delete this file--This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:--```bash-git rm "tasks/monetization-feature/24-subscription-management-ui.md"-```--Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.diff --git a/tests/agent-monetization.test.js b/tests/agent-monetization.test.jsindex e899eeb28..9d4e94287 100644--- a/tests/agent-monetization.test.js+++ b/tests/agent-monetization.test.js@@ -501,6 +501,8 @@ describe('Withdrawals', () => {it('owner can request a withdrawal when balance is sufficient', async () => {authState.session = { id: 'user-1' };+ // payout wallet resolution (destination is server-resolved, not client-supplied)+ sqlState.queue.push([{ address: 'So11111111111111111111111111111111111111112' }]);// balance checksqlState.queue.push([{ earned: 10_000_000n, pending_amount: 0n }]);// insert withdrawal@@ -533,6 +535,8 @@ describe('Withdrawals', () => {it('over-withdrawal is rejected with 422', async () => {authState.session = { id: 'user-1' };+ // payout wallet resolution (destination is server-resolved, not client-supplied)+ sqlState.queue.push([{ address: 'So11111111111111111111111111111111111111112' }]);// available: 2_000_000, request: 9_999_999_999sqlState.queue.push([{ earned: 2_000_000n, pending_amount: 0n }]);diff --git a/tests/api/oauth-token.test.js b/tests/api/oauth-token.test.jsindex 6dcd4dead..d3b9f39f5 100644--- a/tests/api/oauth-token.test.js+++ b/tests/api/oauth-token.test.js@@ -316,7 +316,7 @@ describe('/api/oauth/token — authorization_code grant', () => {it('issues access + refresh on success and consumes the auth code', async () => {sqlState.queue.push([PUBLIC_CLIENT]); // clientsqlState.queue.push([AUTH_CODE_ROW]); // code lookup- sqlState.queue.push([]); // mark code consumed+ sqlState.queue.push([{ code: 'authcode' }]); // atomic consume returns the rowconst { status, body } = await invoke({ formBody: baseForm });expect(status).toBe(200);expect(body.token_type).toBe('Bearer');@@ -343,7 +343,7 @@ describe('/api/oauth/token — authorization_code grant', () => {const noRefresh = { ...PUBLIC_CLIENT, grant_types: ['authorization_code'] };sqlState.queue.push([noRefresh]);sqlState.queue.push([AUTH_CODE_ROW]);- sqlState.queue.push([]);+ sqlState.queue.push([{ code: 'authcode' }]); // atomic consume returns the rowconst { status, body } = await invoke({ formBody: baseForm });expect(status).toBe(200);expect(body.refresh_token).toBeUndefined();diff --git a/tests/api/widgets.test.js b/tests/api/widgets.test.jsindex e0aa79918..a253ed244 100644--- a/tests/api/widgets.test.js+++ b/tests/api/widgets.test.js@@ -40,6 +40,10 @@ vi.mock('../../api/_lib/auth.js', () => ({},}));+vi.mock('../../api/_lib/csrf.js', () => ({+ requireCsrf: vi.fn(async () => true),+}));+const rlState = { success: true };vi.mock('../../api/_lib/rate-limit.js', () => ({