Skip to content

fix: emoji/UTF-8 listing validation (#506) and stale price caches after update (#507) - #548

Merged
barry01-hash merged 1 commit into
PromptMintLabs:mainfrom
Hey-Yetunde:fix/price-cache-emoji-updates
Aug 31, 2026
Merged

fix: emoji/UTF-8 listing validation (#506) and stale price caches after update (#507)#548
barry01-hash merged 1 commit into
PromptMintLabs:mainfrom
Hey-Yetunde:fix/price-cache-emoji-updates

Conversation

@Hey-Yetunde

Copy link
Copy Markdown
Contributor

Summary

Fixes two reported bugs:

#506 — create_prompt fails when preview/title contains emoji

Root cause: The frontend validated title/preview using JS .length (UTF-16 code units) while the on-chain PromptHash contract enforces its MAX_*_LEN limits in UTF-8 bytes (soroban_sdk::String::len()). An emoji is 2 UTF-16 units but 4 UTF-8 bytes, so a title/preview that "fits" the client cap was still rejected on-chain with InvalidFieldLength.

Fix:

  • src/lib/validation/listing.ts: added exported utf8Length() (UTF-8 byte length) and switched imageUrl, title, category, and previewText validation to it, with byte-accurate error messages — the client now enforces exactly what the contract enforces.
  • src/pages/sell/CreatePromptForm.tsx: title/preview live counters now show UTF-8 byte usage so users see the true remaining budget.
  • contracts/prompt-hash/src/contract.rs: documented the UTF-8 byte semantics of validate_len and the matching client-side check.
  • Tests: src/test/listingValidation.test.ts (5 tests) covering emoji within/over the byte limits.

#507 — stale React Query cache after price update

Root cause: After update_prompt_price, the invalidation helpers only invalidated ["marketplace-prompts"], ["created-prompts"], ["purchased-prompts"], ["saved-prompts"], ["prompt-access"]. The prompt detail view (["prompt-detail", id] — browse modal and /prompt/:id) and the cart price snapshot (["marketplace-prompts-cache"]) read price from separate keys that were never invalidated, so they kept showing the old price until a manual refresh.

Fix:

  • src/hooks/useContractSync.ts: invalidateAllPromptQueries now also invalidates ["prompt-detail"] (prefix match covers every id) and ["marketplace-prompts-cache"].
  • src/pages/sell/MyPrompts.tsx: refreshPromptLists invalidates the same two keys after a price update.
  • src/hooks/useContractSync.test.ts: updated for the two new keys (7 invalidations).

Verification

  • yarn vitest run: new + updated suites green — useContractSync.test.ts (8), listing.test.ts, listingValidation.test.ts (5).
  • No new failures in the full suite vs main (the remaining failures — dashboard/checkout/PromptCard/API unlock/etc. — are pre-existing on main).
  • eslint on changed files: 0 errors.
  • tsc -b: no errors in changed files (the repo's remaining typecheck errors are pre-existing on main).

Note: contracts/prompt-hash/src/test.rs and the contract lib have pre-existing compile breakage on main unrelated to these issues.

Closes #506
Closes #507

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Hey-Yetunde Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@barry01-hash
barry01-hash merged commit 887acea into PromptMintLabs:main Aug 31, 2026
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.

Fix: stale React Query cache after price update Fix: create_prompt fails when preview contains emoji

2 participants