Skip to content

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.

fix(dev-plans): report unavailable wallet payments as a clear 503 and show quota reset as a future time

nirholas26caa85504ec
diff --git a/api/_lib/dev-plans/billing.js b/api/_lib/dev-plans/billing.js
index d40b7c9d1..1734014ae 100644
--- a/api/_lib/dev-plans/billing.js
+++ b/api/_lib/dev-plans/billing.js
@@ -187,7 +187,15 @@ export async function createDevPlanCheckout({ userId, planId, asset, wallet = nu
const sub = await getDevSubscription(userId, { fresh: true });
const quote = quoteDevPlanChange(sub, planId, asset);
if (asset !== 'credits') assertWallet(wallet);
- const payTo = asset === 'credits' ? null : treasuryWallet();
+ let payTo = null;
+ if (asset !== 'credits') {
+ try {
+ payTo = treasuryWallet();
+ assetConfig(asset);
+ } catch (err) {
+ throw fail(503, 'payments_not_configured', `${asset} payments are not available right now; pay with credits or try again shortly`);
+ }
+ }
const priced = await priceInAsset(asset, quote.amountUsd);
const expiresAt = new Date(Date.now() + DEV_PLAN_CHECKOUT_TTL_MS).toISOString();
diff --git a/src/dashboard-next/pages/developers-plan.js b/src/dashboard-next/pages/developers-plan.js
index ae0d38c70..636778691 100644
--- a/src/dashboard-next/pages/developers-plan.js
+++ b/src/dashboard-next/pages/developers-plan.js
@@ -9,10 +9,24 @@
// transfer and this tab shows recipient, amount, asset and chain before the
// wallet is asked to sign. Credits are debited server side.
-import { get, post, esc, relTime, ApiError } from '../api.js';
+import { get, post, esc, ApiError } from '../api.js';
import { errorStateHTML, skeletonHTML } from '../../shared/state-kit.js';
import { getAdapter, isUserRejection } from '../../onchain/adapters/index.js';
+/** "in 12 days", "in 8 min", or "now" for a moment already past. The shared formatter only reads the past. */
+function untilTime(iso) {
+ const t = new Date(iso).getTime();
+ if (!Number.isFinite(t)) return '';
+ const s = Math.round((t - Date.now()) / 1000);
+ if (s <= 0) return 'now';
+ if (s < 60) return `in ${s}s`;
+ const m = Math.round(s / 60);
+ if (m < 60) return `in ${m} min`;
+ const h = Math.round(m / 60);
+ if (h < 48) return `in ${h} h`;
+ return `in ${Math.round(h / 24)} days`;
+}
+
const CONFIRM_POLL_MS = 3000;
const CONFIRM_MAX_TRIES = 20;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -96,7 +110,7 @@ function paint(el, ctx) {
</div>
<div class="dev-plan-usage-meta">
<span>${fmtInt(q.remaining)} remaining</span>
- <span>resets ${esc(relTime(q.reset_at))}</span>
+ <span>resets ${esc(untilTime(q.reset_at))}</span>
</div>
${pct >= 100
? `<div class="dev-plan-over">Quota reached. Calls answer <code>402 quota_exceeded</code> until ${periodEnds}${mine.next_plan ? `, or upgrade to ${esc(mine.next_plan.name)} for ${fmtInt(mine.next_plan.included_calls)} calls.` : '.'}</div>`
@@ -302,7 +316,7 @@ async function walletFlow({ asset, planId, target, go, review, showErr, close, t
<div><dt>From</dt><dd><code class="dn-mono-sm">${esc(address)}</code></dd></div>
<div><dt>Chain</dt><dd>Solana mainnet</dd></div>
<div><dt>Buys</dt><dd>${esc(target.name)} until ${fmtDate(c.period_end)}</dd></div>
- <div><dt>Quote expires</dt><dd>${esc(relTime(c.expires_at))}</dd></div>
+ <div><dt>Quote expires</dt><dd>${esc(untilTime(c.expires_at))}</dd></div>
</dl>
`;
go.disabled = false;