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(x402): stop the legacy per-skill invoke failing after the buyer paid
nirholas5edff0a92af1
diff --git a/api/_lib/migrations/20260930140000_agent_payment_intents_consumed_status.sql b/api/_lib/migrations/20260930140000_agent_payment_intents_consumed_status.sqlnew file mode 100644index 000000000..6b8f53a1f--- /dev/null+++ b/api/_lib/migrations/20260930140000_agent_payment_intents_consumed_status.sql@@ -0,0 +1,22 @@+-- Migration: let a paid agent-skill intent reach its terminal 'consumed' state.+-- Apply: node scripts/apply-migrations.mjs --apply --file 20260930140000_agent_payment_intents_consumed_status.sql+-- Idempotent.+--+-- consumeIntent() in api/_lib/x402.js flips an intent paid -> consumed as the+-- single-use lock before the paid skill runs, and releaseIntent() flips it back+-- when the skill fails. The original table (2026-04-29-agent-payments.sql)+-- only allowed pending / paid / expired / failed, so the UPDATE raised a check+-- violation AFTER the buyer had already paid on chain: every legacy per-skill+-- invoke died with a 500 and no revenue was ever recorded. Widen the check to+-- include 'consumed'. Every existing row already satisfies the wider set.++begin;++alter table agent_payment_intents+ drop constraint if exists agent_payment_intents_status_check;++alter table agent_payment_intents+ add constraint agent_payment_intents_status_check+ check (status in ('pending', 'paid', 'consumed', 'expired', 'failed'));++commit;diff --git a/api/_lib/x402.js b/api/_lib/x402.jsindex 855bd2c01..4c7ae697d 100644--- a/api/_lib/x402.js+++ b/api/_lib/x402.js@@ -48,6 +48,7 @@import { sql } from './db.js';import { json, error } from './http.js';+import { resolvePayoutAddress } from './payout.js';import { resolveSolanaRecipient } from '../../src/solana/sns.js';export const X402_VERSION = 'x402/0.1';@@ -62,11 +63,6 @@ export const X402_VERSION = 'x402/0.1';// a raw key.async function resolveRecipient({ agent, payments }) {const receiver = payments?.receiver;- const metaName = agent?.meta?.sns_domain || null;- const metaNameFull = metaName- ? (metaName.endsWith('.sol') ? metaName : `${metaName}.sol`)- : null;-const { address, resolved_from } = await resolveSolanaRecipient(receiver || '');if (resolved_from) {return { recipient: address, recipient_name: resolved_from };@@ -75,7 +71,39 @@ async function resolveRecipient({ agent, payments }) {// agent has stored. Most agents store a base58 wallet here; some legacy// records may use a non-base58 placeholder. We don't gatekeep at this// layer; the wallet adapter / payment program will validate at sign-time.- return { recipient: address ?? (receiver || null), recipient_name: metaNameFull };+ return { recipient: address ?? (receiver || null), recipient_name: snsDisplayName(agent) };+}++function snsDisplayName(agent) {+ const metaName = agent?.meta?.sns_domain || null;+ if (!metaName) return null;+ return metaName.endsWith('.sol') ? metaName : `${metaName}.sol`;+}++/**+ * The one recipient rule for an agent-skill manifest, shared by the 402+ * challenge (emit402) and the prefetch manifest (manifestOnly), so a buyer who+ * reads the manifest first and then hits the 402 is never shown two different+ * wallets. Order: the owner's payout wallet for the chain (agent_payout_wallets),+ * then the agent's own wallet_address (both via resolvePayoutAddress), then the+ * receiver stored in meta.payments (a base58 wallet or a .sol name).+ *+ * @param {{ agent: object, chain?: string }} opts+ * @returns {Promise<{ recipient: string | null, recipient_name: string | null }>}+ */+export async function resolveSkillRecipient({ agent, chain = 'solana' }) {+ const payout = agent?.id ? await resolvePayoutAddress(agent.id, chain) : null;+ if (payout) return { recipient: payout, recipient_name: snsDisplayName(agent) };+ const payments = agent?.meta?.payments || agent?.payments;+ return resolveRecipient({ agent, payments });+}++/**+ * The prefetch URL for an agent-skill manifest. This is the route vercel.json+ * actually serves (`/api/agents/x402/manifest`), not a path-style alias.+ */+export function manifestUrl(agentId, skill) {+ return `/api/agents/x402/manifest?agent_id=${encodeURIComponent(agentId)}&skill=${encodeURIComponent(skill)}`;}/**@@ -87,15 +115,16 @@ async function resolveRecipient({ agent, payments }) {* @param {string} opts.skill Skill identifier (free-form, used by the manifest).* @param {string} opts.amount Raw token units as a numeric string.* @param {string} opts.currency Mint pubkey (base58) for the currency token.+ * @param {string} [opts.chain='solana'] Chain the price is denominated on.* @param {number} [opts.validForSec=900] Manifest validity in seconds (default 15m).*/-export async function emit402(res, { agent, skill, amount, currency, validForSec = 900 }) {+export async function emit402(res, { agent, skill, amount, currency, chain = 'solana', validForSec = 900 }) {const payments = agent?.meta?.payments || agent?.payments;if (!payments?.configured) {// Misconfigured: we shouldn't gate a skill behind 402 if payments aren't on.return error(res, 500, 'misconfigured', 'agent has no payments config');}- const { recipient, recipient_name } = await resolveRecipient({ agent, payments });+ const { recipient, recipient_name } = await resolveSkillRecipient({ agent, chain });if (!recipient) {return error(res, 412, 'recipient_unresolved', 'agent payments.receiver could not be resolved to a wallet');}@@ -107,12 +136,14 @@ export async function emit402(res, { agent, skill, amount, currency, validForSecskill,amount: String(amount),currency,+ chain,recipient,recipient_name,memo: String(Math.floor(Date.now() / 1000)),valid_until: validUntil,intent_url: '/api/agents/payments/pay-prep',verify_url: '/api/agents/payments/pay-confirm',+ manifest_url: manifestUrl(agent.id, skill),retry_with_header: 'x-payment-intent',};res.statusCode = 402;@@ -121,7 +152,7 @@ export async function emit402(res, { agent, skill, amount, currency, validForSec// Hint the canonical manifest URL so x402 clients can prefetch.res.setHeader('link',- `</.well-known/x402>; rel="payment-config", </api/agents/${agent.id}/x402/${encodeURIComponent(skill)}/manifest>; rel="payment-manifest"`,+ `</.well-known/x402>; rel="payment-config", <${manifestUrl(agent.id, skill)}>; rel="payment-manifest"`,);res.end(JSON.stringify(manifest));return true;@@ -129,26 +160,33 @@ export async function emit402(res, { agent, skill, amount, currency, validForSec/*** Read x-payment-intent (or x-payment-tx-sig) headers and verify the request- * is paid for `agentId` + `skill`. Returns the verified intent row, or null- * if not paid (caller should `emit402`).+ * is paid for `agentId` + `skill` BY `payerUserId`. Returns the verified intent+ * row, or null if not paid (caller should `emit402`).+ *+ * The intent is bound to the account that paid it: pay-prep stamps+ * payer_user_id, and only that account may redeem the intent. Without the+ * binding, anyone who saw an intent id (a log line, a shared screenshot, a+ * proxy) could spend another buyer's payment on their own call.** @param {import('http').IncomingMessage} req- * @param {{ agentId: string, skill: string, expectedAmount?: string, expectedCurrency?: string }} ctx+ * @param {{ agentId: string, skill: string, payerUserId: string, expectedAmount?: string, expectedCurrency?: string }} ctx* @returns {Promise<null | { intentId: string, amount: string, currency: string, paidAt: Date }>}*/-export async function verifyPaid(req, { agentId, skill, expectedAmount, expectedCurrency }) {+export async function verifyPaid(req, { agentId, skill, payerUserId, expectedAmount, expectedCurrency }) {if (!expectedAmount) throw new Error('verifyPaid: expectedAmount is required');if (!expectedCurrency) throw new Error('verifyPaid: expectedCurrency is required');+ if (!payerUserId) throw new Error('verifyPaid: payerUserId is required');const intentId = (req.headers['x-payment-intent'] || '').toString().trim();if (!intentId) return null;const [row] = await sql`- select id, agent_id, currency_mint, amount, status, paid_at, payload, end_time+ select id, agent_id, payer_user_id, currency_mint, amount, status, paid_at, payload, end_timefrom agent_payment_intentswhere id = ${intentId} and agent_id = ${agentId}limit 1`;if (!row) return null;+ if (String(row.payer_user_id) !== String(payerUserId)) return null;if (row.status !== 'paid') return null;if (row.end_time && new Date(row.end_time).getTime() < Date.now()) return null;@@ -209,27 +247,14 @@ export async function releaseIntent(intentId) {}/**- * Helper: respond with the manifest only (no 402), for prefetch/discovery- * via `GET /api/agents/:id/x402/:skill/manifest`.+ * Helper: respond with the manifest only (no 402), for prefetch/discovery via+ * `GET /api/agents/x402/manifest?agent_id=&skill=`. The recipient comes from+ * resolveSkillRecipient, the same rule emit402 uses.*/export async function manifestOnly(res, opts) {const validUntil = Math.floor(Date.now() / 1000) + (opts.validForSec || 900);-- // Prefer an explicit payout `recipient` (resolved from agent_payout_wallets /- // the agent's own wallet_address by the caller). Only when none is supplied do- // we fall back to resolving the agent's configured meta receiver via SNS — this- // keeps pre-payout-wallet agents working unchanged.- let recipient = opts.recipient ?? null;- let recipient_name = null;- if (recipient) {- const metaName = opts.agent.meta?.sns_domain || null;- recipient_name = metaName- ? (metaName.endsWith('.sol') ? metaName : `${metaName}.sol`)- : null;- } else {- const payments = opts.agent.meta?.payments || opts.agent.payments;- ({ recipient, recipient_name } = await resolveRecipient({ agent: opts.agent, payments }));- }+ const chain = opts.chain ?? 'solana';+ const { recipient, recipient_name } = await resolveSkillRecipient({ agent: opts.agent, chain });return json(res, 200, {version: X402_VERSION,@@ -238,12 +263,13 @@ export async function manifestOnly(res, opts) {skill: opts.skill,amount: String(opts.amount),currency: opts.currency,- chain: opts.chain ?? 'solana',+ chain,recipient,recipient_name,valid_until: validUntil,intent_url: '/api/agents/payments/pay-prep',verify_url: '/api/agents/payments/pay-confirm',+ manifest_url: manifestUrl(opts.agent.id, opts.skill),retry_with_header: 'x-payment-intent',});}diff --git a/api/agents/x402/[action].js b/api/agents/x402/[action].jsindex 276870d9e..b947b7451 100644--- a/api/agents/x402/[action].js+++ b/api/agents/x402/[action].js@@ -7,7 +7,6 @@ import { cors, json, method, readJson, wrap, error, rateLimited } from '../../_limport { limits, clientIp } from '../../_lib/rate-limit.js';import { parse, isUuid } from '../../_lib/validate.js';import { emit402, verifyPaid, consumeIntent, releaseIntent, manifestOnly } from '../../_lib/x402.js';-import { resolvePayoutAddress } from '../../_lib/payout.js';import { calculateFee } from '../../_lib/fee.js';import { insertNotification } from '../../_lib/notify.js';import { hasSkillAccess, consumeTrialUse, logSkillUsage } from '../../_lib/skill-access.js';@@ -204,6 +203,7 @@ async function handleInvoke(req, res) {const paid = await verifyPaid(req, {agentId: agent.id,skill: body.skill,+ payerUserId: auth.userId,expectedAmount: price.amount,expectedCurrency: price.currency,});@@ -213,6 +213,7 @@ async function handleInvoke(req, res) {skill: body.skill,amount: price.amount,currency: price.currency,+ chain: price.chain ?? 'solana',});// $THREE holder gate — agents can require callers to hold a minimum $THREE@@ -334,18 +335,15 @@ async function handleManifest(req, res) {}}- // payTo resolves from the owner's configured payout wallet for this chain- // (agent_payout_wallets), falling back to the agent's own wallet_address.- // When neither is set, manifestOnly falls back to the agent's meta receiver.- const recipient = await resolvePayoutAddress(agent.id, price.chain || 'solana');-+ // The recipient is resolved inside manifestOnly by resolveSkillRecipient,+ // the same rule the invoke path's 402 uses: payout wallet, then the agent's+ // own wallet, then the meta.payments receiver.return manifestOnly(res, {agent,skill,amount: price.amount,currency: price.currency,chain: price.chain,- recipient,});}diff --git a/tests/agent-monetization.test.js b/tests/agent-monetization.test.jsindex 7fd04949a..f8d30d3bb 100644--- a/tests/agent-monetization.test.js+++ b/tests/agent-monetization.test.js@@ -347,6 +347,7 @@ describe('Revenue Attribution', () => {{id: intentId,agent_id: agent.id,+ payer_user_id: session.id,currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',amount: '1000000',status: 'paid',@@ -411,6 +412,7 @@ describe('Revenue Attribution', () => {sqlState.queue.push([{id: intentId,agent_id: agent.id,+ payer_user_id: session.id,currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',amount: '1000000',status: 'paid',@@ -445,6 +447,43 @@ describe('Revenue Attribution', () => {expect(second).toBe(402);});+ // Legacy defect: verifyPaid matched an intent by id + agent only, so any+ // signed-in caller who learned another buyer's intent id could spend that+ // buyer's payment on their own call. The intent is bound to its payer now.+ it('an intent paid by a different account is refused and never consumed', async () => {+ const { agent, session } = createTestAgent();+ authState.session = session;+ const intentId = 'intent-stolen-001';++ sqlState.queue.push([agent]);+ sqlState.queue.push([]); // priceFor → meta fallback+ sqlState.queue.push([]); // hasSkillAccess → x402 path+ sqlState.queue.push([{+ id: intentId,+ agent_id: agent.id,+ payer_user_id: 'someone-else',+ currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',+ amount: '1000000',+ status: 'paid',+ paid_at: new Date().toISOString(),+ payload: null,+ end_time: null,+ }]);++ const { status } = await invoke(x402Handler, {+ method: 'POST',+ url: '/api/agents/x402/invoke',+ headers: { 'x-payment-intent': intentId },+ body: { agent_id: agent.id, skill: 'echo', args: {} },+ });++ expect(status).toBe(402);+ const intentQuery = sqlState.calls.find((c) => String(c.query).includes('from agent_payment_intents'));+ expect(String(intentQuery.query)).toContain('payer_user_id');+ expect(sqlState.calls.some((c) => String(c.query).includes("set status = 'consumed'"))).toBe(false);+ expect(sqlState.calls.some((c) => String(c.query).includes('agent_revenue_events'))).toBe(false);+ });+// ── consume-first single-use lock (2026-07-23 audit) ─────────────────────// The handler used to execute the skill BEFORE consuming the intent: two// concurrent invokes both passed verifyPaid and BOTH delivered the paid@@ -462,6 +501,7 @@ describe('Revenue Attribution', () => {sqlState.queue.push([{id: intentId,agent_id: agent.id,+ payer_user_id: session.id,currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',amount: '1000000',status: 'paid',@@ -500,6 +540,7 @@ describe('Revenue Attribution', () => {sqlState.queue.push([{id: intentId,agent_id: agent.id,+ payer_user_id: session.id,currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',amount: '1000000',status: 'paid',diff --git a/tests/agent-payment-intents-consumed.test.js b/tests/agent-payment-intents-consumed.test.jsnew file mode 100644index 000000000..8dced3413--- /dev/null+++ b/tests/agent-payment-intents-consumed.test.js@@ -0,0 +1,101 @@+// consumeIntent() against the REAL agent_payment_intents check constraint.+//+// The legacy per-skill x402 invoke consumes a paid intent (paid -> consumed)+// as its single-use lock. The table's original check constraint only allowed+// pending / paid / expired / failed, so that UPDATE raised a check violation+// after the buyer had already paid on chain. Mocked-SQL tests could never see+// it, so this suite runs the helper against an in-process Postgres (PGlite)+// built from the actual migration files: the original CREATE TABLE, then the+// widening migration.++import { readFileSync } from 'node:fs';+import { describe, it, expect, beforeEach, vi } from 'vitest';+import { PGlite } from '@electric-sql/pglite';++const dbState = { pg: null };++vi.mock('../api/_lib/db.js', () => {+ const sql = async (strings, ...values) => {+ const text = strings.reduce((acc, part, i) => acc + part + (i < values.length ? `$${i + 1}` : ''), '');+ const out = await dbState.pg.query(text, values);+ return out.rows;+ };+ return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };+});++const { consumeIntent, releaseIntent } = await import('../api/_lib/x402.js');++const MIG_DIR = new URL('../api/_lib/migrations/', import.meta.url);++// The original CREATE TABLE, lifted verbatim from the migration that shipped+// it. The two foreign keys point at users / agent_identities, which this+// isolated database does not have, so only those clauses are dropped; every+// column, default and CHECK is kept exactly as production got it.+function originalIntentsDdl() {+ const src = readFileSync(new URL('2026-04-29-agent-payments.sql', MIG_DIR), 'utf8');+ const start = src.indexOf('create table if not exists agent_payment_intents');+ const end = src.indexOf(');', start) + 2;+ expect(start).toBeGreaterThan(-1);+ return src+ .slice(start, end)+ .replace(/--[^\n]*/g, '')+ .replace(/\s+references\s+\w+\(id\)\s+on delete cascade/g, '');+}++const WIDEN = readFileSync(+ new URL('20260930140000_agent_payment_intents_consumed_status.sql', MIG_DIR),+ 'utf8',+);++async function seedPaidIntent(id) {+ await dbState.pg.query(+ `insert into agent_payment_intents+ (id, payer_user_id, agent_id, currency_mint, amount, memo, start_time, end_time,+ status, cluster, payload, expires_at)+ values ($1, gen_random_uuid(), gen_random_uuid(), 'mint', '1000000', '1',+ now(), now() + interval '1 day', 'paid', 'mainnet', '{}'::jsonb, now() + interval '1 day')`,+ [id],+ );+}++async function statusOf(id) {+ const { rows } = await dbState.pg.query('select status from agent_payment_intents where id = $1', [id]);+ return rows[0]?.status;+}++beforeEach(async () => {+ dbState.pg = new PGlite();+ await dbState.pg.exec(originalIntentsDdl());+});++describe('agent_payment_intents status constraint', () => {+ it('rejects consumeIntent under the original constraint (the production failure)', async () => {+ await seedPaidIntent('intent-old');+ await expect(consumeIntent('intent-old')).rejects.toThrow(/agent_payment_intents_status_check/);+ expect(await statusOf('intent-old')).toBe('paid');+ });++ it('consumeIntent succeeds once the widening migration is applied', async () => {+ await dbState.pg.exec(WIDEN);+ await seedPaidIntent('intent-new');+ expect(await consumeIntent('intent-new')).toBe(true);+ expect(await statusOf('intent-new')).toBe('consumed');+ // Single use: the second claim loses.+ expect(await consumeIntent('intent-new')).toBe(false);+ });++ it('releaseIntent restores a consumed intent to paid so the buyer can retry', async () => {+ await dbState.pg.exec(WIDEN);+ await seedPaidIntent('intent-release');+ await consumeIntent('intent-release');+ expect(await releaseIntent('intent-release')).toBe(true);+ expect(await statusOf('intent-release')).toBe('paid');+ });++ it('the migration is idempotent', async () => {+ await dbState.pg.exec(WIDEN);+ await dbState.pg.exec(WIDEN);+ await seedPaidIntent('intent-twice');+ expect(await consumeIntent('intent-twice')).toBe(true);+ });+});diff --git a/tests/api/x402.test.js b/tests/api/x402.test.jsindex 599a19eb3..e284682fe 100644--- a/tests/api/x402.test.js+++ b/tests/api/x402.test.js@@ -1,12 +1,38 @@/**- * Tests for the x402 helper. Pure-logic only — no DB, no fetch.+ * Tests for the legacy agent-skill x402 helper (emit402 / manifestOnly).*- * verifyPaid touches the DB (via _lib/db.js); we exercise emit402 and- * manifestOnly, which are stateless transformations of agent + skill.+ * Both resolve the recipient through resolveSkillRecipient, which reads the+ * owner's payout wallet (agent_payout_wallets) and the agent's own wallet+ * before falling back to meta.payments.receiver. The DB is mocked with a tiny+ * table of those two lookups so each test states which wallets exist.*/-import { describe, it, expect } from 'vitest';-import { emit402, manifestOnly, X402_VERSION } from '../../api/_lib/x402.js';+import { readFileSync } from 'node:fs';+import { describe, it, expect, beforeEach, vi } from 'vitest';++const walletState = { payout: null, agentWallet: null };++vi.mock('../../api/_lib/db.js', () => ({+ sql: vi.fn(async (strings) => {+ const q = strings.join('?');+ if (q.includes('agent_payout_wallets')) {+ return walletState.payout ? [{ address: walletState.payout }] : [];+ }+ if (q.includes('wallet_address from agent_identities')) {+ return walletState.agentWallet ? [{ wallet_address: walletState.agentWallet }] : [];+ }+ return [];+ }),+ isDbUnavailableError: () => false,+ isDbCapacityError: () => false,+}));++const { emit402, manifestOnly, manifestUrl, X402_VERSION } = await import('../../api/_lib/x402.js');++beforeEach(() => {+ walletState.payout = null;+ walletState.agentWallet = null;+});function makeRes() {return {@@ -180,3 +206,70 @@ describe('manifestOnly', () => {expect(body.amount).toBe('5000');});});++function captureRes() {+ return {+ statusCode: 0,+ headers: {},+ body: null,+ setHeader(k, v) {+ this.headers[k.toLowerCase()] = v;+ },+ getHeader(k) {+ return this.headers[k.toLowerCase()];+ },+ end(body) {+ this.body = body;+ },+ };+}++// Legacy defect: emit402 advertised /api/agents/:id/x402/:skill/manifest in its+// Link header, a path no route serves, so a client that prefetched the+// manifest got a 404. The link must be a URL the live route table resolves.+describe('emit402 manifest link', () => {+ it('points at the manifest route vercel.json actually serves', async () => {+ const res = captureRes();+ await emit402(res, { agent: makeAgent(), skill: 'summarize', amount: '1', currency: 'X' });+ const link = res.headers['link'];+ const target = link.match(/<([^>]+)>; rel="payment-manifest"/)[1];+ const pathOnly = target.split('?')[0];+ const routes = JSON.parse(readFileSync(new URL('../../vercel.json', import.meta.url), 'utf8')).routes;+ const served = routes.some((r) => r.src && new RegExp(`^${r.src}$`).test(pathOnly) && String(r.dest).includes('action=manifest'));+ expect(served).toBe(true);+ expect(target).toBe(manifestUrl('agent-uuid', 'summarize'));+ expect(new URL(target, 'https://three.ws').searchParams.get('agent_id')).toBe('agent-uuid');+ expect(new URL(target, 'https://three.ws').searchParams.get('skill')).toBe('summarize');+ });+});++// Legacy defect: the 402 named meta.payments.receiver while the manifest named+// the owner's payout wallet, so one skill advertised two different recipients.+describe('emit402 and manifestOnly agree on the recipient', () => {+ async function bothRecipients() {+ const r402 = captureRes();+ await emit402(r402, { agent: makeAgent(), skill: 's', amount: '1', currency: 'X' });+ const rManifest = captureRes();+ await manifestOnly(rManifest, { agent: makeAgent(), skill: 's', amount: '1', currency: 'X' });+ return [JSON.parse(r402.body).recipient, JSON.parse(rManifest.body).recipient];+ }++ it('both use the owner payout wallet when one is configured', async () => {+ walletState.payout = 'PayoutWa11et1111111111111111111111111111111';+ const [a, b] = await bothRecipients();+ expect(a).toBe('PayoutWa11et1111111111111111111111111111111');+ expect(b).toBe(a);+ });++ it('both fall back to the agent wallet, then the meta receiver', async () => {+ walletState.agentWallet = 'AgentOwnWa11et11111111111111111111111111111';+ const [a, b] = await bothRecipients();+ expect(a).toBe('AgentOwnWa11et11111111111111111111111111111');+ expect(b).toBe(a);++ walletState.agentWallet = null;+ const [c, d] = await bothRecipients();+ expect(c).toBe('THREEsynthetic1111111111111111111111111PayTo');+ expect(d).toBe(c);+ });+});