fix: emoji/UTF-8 listing validation (#506) and stale price caches after update (#507) - #548
Merged
barry01-hash merged 1 commit intoAug 31, 2026
Conversation
…nd stale price caches (PromptMintLabs#507)
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 itsMAX_*_LENlimits 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 withInvalidFieldLength.Fix:
src/lib/validation/listing.ts: added exportedutf8Length()(UTF-8 byte length) and switchedimageUrl,title,category, andpreviewTextvalidation 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 ofvalidate_lenand the matching client-side check.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:invalidateAllPromptQueriesnow also invalidates["prompt-detail"](prefix match covers every id) and["marketplace-prompts-cache"].src/pages/sell/MyPrompts.tsx:refreshPromptListsinvalidates 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).main(the remaining failures — dashboard/checkout/PromptCard/API unlock/etc. — are pre-existing onmain).eslinton changed files: 0 errors.tsc -b: no errors in changed files (the repo's remaining typecheck errors are pre-existing onmain).Note:
contracts/prompt-hash/src/test.rsand the contract lib have pre-existing compile breakage onmainunrelated to these issues.Closes #506
Closes #507