Skip to content

let elixir and energy charge the stablecoin the wallet actually holds - #196

Merged
0xward merged 1 commit into
mainfrom
claude/nullstate-onchain-text-q6g2a3
Jul 30, 2026
Merged

let elixir and energy charge the stablecoin the wallet actually holds#196
0xward merged 1 commit into
mainfrom
claude/nullstate-onchain-text-q6g2a3

Conversation

@0xward

@0xward 0xward commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Owner: "aku barusan test buy elixir, tapi ko gagal? jujur buy elixir aja yg gagal, selain itu berhasil semua" — tested in the OKX browser on Celo.

The bug

Both dollar purchases in DungeonGame.tsx hardcoded USDm:

txHash = await walletRef.current.buyMarketplaceItem(1, 'USDm')
body:   { wallet: addr, txHash, token: 'USDm' }

Every other paid flow asks first. MarketplaceScreen:41 and CraftingScreen:112 call pickBestPaymentToken, which reads the wallet's USDm/USDC/USDT balances and returns whichever it holds the most of. That's also MiniPay's "Dynamic Adaptation" requirement, recorded in MINIPAY-COMPLIANCE-CHECKLIST.md §2.

So a wallet holding USDC but no USDm sent a USDm transfer that moved nothing, and /api/elixir/buy then correctly reported "No matching payment to treasury found in this tx" — it verifies a Transfer(from=buyer, to=treasury, value>=price) in the named token, and there wasn't one.

The failure was honest; the request was wrong. And that is exactly why only elixir failed while everything else worked: everything else asked.

The one you hadn't hit yet

DungeonGame.tsx:156 had the same bug and is energy refill. It would have failed on the same wallet for the same reason — you just hadn't tested it.

The fix

One helper, both call sites, falling back to USDm on a read failure — which is what pickBestPaymentToken does internally too, so a flaky RPC degrades to the old behaviour rather than blocking a sale.

Verification

Guard Result
audit / check:copy / check:market / check:cssvars pass
build:engine pass, no drift
npx tsc --noEmit pass
npm run build pass
npm run lint 34 — unchanged from main

Not verifiable from here. This needs a real wallet holding a non-USDm stablecoin — the same limitation the note at lib/contract-abi.ts:48 already records about confirming pickBestPaymentToken. Worth retesting elixir and energy refill on the wallet that failed.


Generated by Claude Code

Owner: "aku barusan test buy elixir, tapi ko gagal? jujur buy elixir aja yg
gagal, selain itu berhasil semua" — tested in the OKX browser on Celo.

Both dollar purchases in DungeonGame hardcoded USDm:

    txHash = await walletRef.current.buyMarketplaceItem(1, 'USDm')
    body:   { wallet: addr, txHash, token: 'USDm' }

Every other paid flow asks first. MarketplaceScreen:41 and CraftingScreen:112
call pickBestPaymentToken, which reads the wallet's USDm/USDC/USDT balances and
returns whichever it holds the most of. That is also MiniPay's "Dynamic
Adaptation" requirement, recorded in MINIPAY-COMPLIANCE-CHECKLIST.md §2.

So a wallet holding USDC but no USDm sent a USDm transfer that moved nothing,
and /api/elixir/buy then correctly reported "No matching payment to treasury
found in this tx" — it verifies a Transfer(from=buyer, to=treasury,
value>=price) in the named token, and there wasn't one. The failure was honest;
the request was wrong.

That is exactly why only elixir failed while everything else worked: everything
else asked.

Line 156 had the same bug and is ENERGY REFILL, which the owner had not tested
yet. It would have failed on the same wallet for the same reason.

One helper, both call sites, falling back to USDm on a read failure — which is
what pickBestPaymentToken does internally too, so a flaky RPC degrades to the
old behaviour rather than blocking a sale.

Not verifiable from here: this needs a real wallet holding a non-USDm
stablecoin, which is the same limitation the note in lib/contract-abi.ts:48
already records about confirming pickBestPaymentToken.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017A764RdnwpyWnG7uCNhMiQ
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nullstate Ready Ready Preview Jul 30, 2026 11:14am

@0xward
0xward merged commit b0ee6a0 into main Jul 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant