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(tokenize): hold the remix royalty until the payer's x402 payment has settled instead of paying it from the treasury first

nirholas62196da58e67
diff --git a/tests/tokenize-3d-remix-royalty.test.js b/tests/tokenize-3d-remix-royalty.test.js
index 02ba8c856..76f45300c 100644
--- a/tests/tokenize-3d-remix-royalty.test.js
+++ b/tests/tokenize-3d-remix-royalty.test.js
@@ -106,3 +106,34 @@ describe('settleTokenizeRemixRoyalty', () => {
expect(result.royalty_bps).toBeLessThan(9999);
});
});
+
+describe('settleOrDeferRemixRoyalty', () => {
+ it('pays nothing until the registered post-settlement work runs', async () => {
+ const { settleOrDeferRemixRoyalty } = await import('../api/_lib/tokenize-3d.js');
+ const updates = [];
+ const sql = async (strings, ...values) => {
+ const text = strings.join('?');
+ if (text.includes('update tokenized_3d_assets')) updates.push(values);
+ return [{ mint: PARENT_MINT, royalty_bps: 1000, royalty_recipient: CREATOR_WALLET }];
+ };
+ const queued = [];
+ const pending = await settleOrDeferRemixRoyalty({
+ sql, rowId: 'row-1', parentMint: PARENT_MINT, network: 'devnet', feeAtomics: MINT_FEE_ATOMICS,
+ defer: (run) => queued.push(run),
+ });
+ expect(pending).toMatchObject({ paid: false, reason: 'pending_payment_settlement' });
+ expect(queued).toHaveLength(1);
+ expect(updates).toHaveLength(0);
+ await queued[0]();
+ expect(updates).toHaveLength(1);
+ expect(JSON.parse(updates[0][0]).reason).toBe('devnet_not_settled');
+ });
+
+ it('settles immediately when there is nothing to wait for', async () => {
+ const { settleOrDeferRemixRoyalty } = await import('../api/_lib/tokenize-3d.js');
+ const out = await settleOrDeferRemixRoyalty({
+ sql: fakeSqlReturning(null), rowId: 'row-2', parentMint: PARENT_MINT, network: 'devnet', feeAtomics: 0n,
+ });
+ expect(out.reason).toBe('devnet_not_settled');
+ });
+});