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
Fix marketplace platform-fee test re-import for Vite static analysis
nirholasf7783f585875
diff --git a/prompts/monetization/14-platform-fee.md b/prompts/monetization/14-platform-fee.mddeleted file mode 100644index 5f59851fa..000000000--- a/prompts/monetization/14-platform-fee.md+++ /dev/null@@ -1,92 +0,0 @@-# Prompt 14: Platform Fee (Backend)--## Objective-Implement a platform fee on every skill purchase transaction, splitting the payment between the skill creator and the platform's treasury wallet.--## Explanation-Platform fees are a standard monetization strategy. This task involves modifying the transaction creation logic to calculate a fee (e.g., 5%) and adding a second transfer instruction to the transaction. This ensures that a portion of every sale is automatically sent to the platform.--## Instructions-1. **Define Platform Wallet and Fee Rate:**- * In your backend configuration (e.g., environment variables), define your platform's Solana wallet address (`PLATFORM_WALLET_ADDRESS`) and the fee percentage (`PLATFORM_FEE_BPS`, in basis points, e.g., 500 for 5%).--2. **Update the Payment Endpoint (`api/payments/prepare-skill-purchase.js`):**- * Inside the handler, after fetching the skill price:- * Calculate the platform fee from the total amount. Be careful with integer division and rounding; it's best to work with `BigInt` for token amounts to avoid precision errors.- * Calculate the amount the creator will receive (total amount - platform fee).- * Create two `createTransferInstruction` calls:- 1. One instruction to transfer the creator's portion to their payout wallet.- 2. A second instruction to transfer the platform fee to the platform's wallet.- * Add both transfer instructions to the same `Transaction` object.--3. **Atomicity:**- * Because both transfers are part of the same transaction, the operation is atomic. If any part of it fails, the entire transaction (both the payment to the creator and the fee to the platform) will fail, ensuring consistency.--## Code Example (Backend - `api/payments/prepare-skill-purchase.js`)--```javascript-// ... (imports)--const PLATFORM_WALLET = new PublicKey(process.env.PLATFORM_WALLET_ADDRESS);-// Fee in basis points (100 bps = 1%)-const PLATFORM_FEE_BPS = BigInt(process.env.PLATFORM_FEE_BPS || 500);--export default async function handler(req, res) {- // ... (handler setup)- try {- // ... (get buyer, creator wallet, price info)-- const transaction = new Transaction({ /* ... */ });- const buyerUsdcAddress = await getAssociatedTokenAddress(USDC_MINT, buyerPublicKey);- const creatorUsdcAddress = await getAssociatedTokenAddress(USDC_MINT, creatorPublicKey);- const platformUsdcAddress = await getAssociatedTokenAddress(USDC_MINT, PLATFORM_WALLET);-- const totalAmount = BigInt(priceInfo.amount);-- // Calculate fees using BigInt for precision- const platformFee = (totalAmount * PLATFORM_FEE_BPS) / 10000n;- const creatorAmount = totalAmount - platformFee;-- // Instruction 1: Transfer to creator- transaction.add(- createTransferInstruction(- buyerUsdcAddress,- creatorUsdcAddress,- buyerPublicKey,- creatorAmount // Use BigInt amount- )- );-- // Instruction 2: Transfer platform fee- if (platformFee > 0) {- transaction.add(- createTransferInstruction(- buyerUsdcAddress,- platformUsdcAddress,- buyerPublicKey,- platformFee // Use BigInt amount- )- );- }-- // ... (serialize and return transaction)-- } catch (error) {- // ... (error handling)- }-}-```--<!-- 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 "prompts/monetization/14-platform-fee.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/api/marketplace-platform-fee.test.js b/tests/api/marketplace-platform-fee.test.jsindex 44f653ca7..e2a840822 100644--- a/tests/api/marketplace-platform-fee.test.js+++ b/tests/api/marketplace-platform-fee.test.js@@ -4,9 +4,15 @@// activates only when both a rate and a treasury wallet are configured, splits// the price correctly, and is clamped to a sane ceiling.-import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';-const FRESH = () => import(`../../api/_lib/marketplace-platform-fee.js?cb=${Math.random()}`);+// Re-import the module fresh each time so its module-level recipient cache does+// not leak env-derived state between cases. vi.resetModules() clears the module+// registry; the static import path keeps it statically analyzable for Vite.+const FRESH = async () => {+ vi.resetModules();+ return import('../../api/_lib/marketplace-platform-fee.js');+};const ENV_KEYS = ['MARKETPLACE_PLATFORM_FEE_BPS',