Skip to content

fix: clarify coin-paid bounty payout labels#405

Open
qingfeng312 wants to merge 1 commit into
profullstack:masterfrom
qingfeng312:fix/bounty-payout-display
Open

fix: clarify coin-paid bounty payout labels#405
qingfeng312 wants to merge 1 commit into
profullstack:masterfrom
qingfeng312:fix/bounty-payout-display

Conversation

@qingfeng312
Copy link
Copy Markdown

Summary

  • Clarifies bounty payout labels when a USD-denominated bounty is paid in a coin equivalent.
  • Treats blank payment_coin values as USD-only.
  • Adds unit coverage for payout label formatting.

Fixes #401

Tests

  • ./node_modules/.bin/vitest run src/lib/bounties.test.ts src/lib/utils.test.ts

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 5, 2026

Greptile Summary

This PR updates the bounty payout label for coin-paid USD bounties from $2 USD (paid in SOL) to $2 USD value, paid in SOL equivalent, and adds a .trim() guard so whitespace-only payment_coin values fall back to the USD-only label. New unit tests cover all four cases: null, undefined, a valid coin, and a blank-whitespace coin.

  • bounties.ts: two-line change in formatBountyPayout — optional chaining + trim() replaces the bare coin check, and the template string is updated to the new wording.
  • bounties.test.ts (new): three focused vitest cases that pin the rendered output for each input variant.

Confidence Score: 5/5

Safe to merge — the change is a two-line label update with a whitespace guard and matching unit tests.

The logic is minimal and well-tested. The only callsites (bounties/page.tsx, bounties/[id]/page.tsx, dashboard/bounties/page.tsx) all pass payment_coin from the database, and the new .trim() path is strictly more defensive than before. Gig-card paths are unaffected and have their own tests.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/bounties.ts Adds paymentCoin?.trim() to treat whitespace-only coins as USD, and updates the label from (paid in X) to X USD value, paid in X equivalent. Logic is correct and JSDoc has a minor inaccuracy in the example amount format.
src/lib/bounties.test.ts New test file covering null, undefined, non-empty coin, and whitespace-only coin cases for formatBountyPayout. Assertions align with the formatCurrency implementation's minimumFractionDigits: 0 behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["formatBountyPayout(amountUsd, paymentCoin)"] --> B["amount = Number(amountUsd)"]
    B --> C["usd = formatCurrency(amount) + ' USD'"]
    C --> D["coin = paymentCoin?.trim()"]
    D --> E{coin truthy?}
    E -- "Yes (e.g. 'SOL')" --> F["Return: '$X USD value, paid in SOL equivalent'"]
    E -- "No (null / undefined / blank)" --> G["Return: '$X USD'"]
Loading

Reviews (1): Last reviewed commit: "fix: clarify coin-paid bounty payout lab..." | Re-trigger Greptile

Comment thread src/lib/bounties.ts
Comment on lines 4 to 9
/**
* Human label for a bounty payout, matching the gig card style:
* "$2.00 USD (paid in SOL)" when a coin is set, otherwise "$2.00 USD".
* "$2.00 USD value, paid in SOL equivalent" when a coin is set,
* otherwise "$2.00 USD".
* Centralized so browse/detail/dashboard stay consistent.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The JSDoc comment still says "matching the gig card style", but GigCard.tsx still uses the old (paid in ${coin}) format — bounties now intentionally diverge from it. The comment should reflect this. The example amount also shows $2.00 USD with a forced two-decimal format, but formatCurrency uses minimumFractionDigits: 0, so a round number like $2 renders as $2 USD, not $2.00 USD.

Suggested change
/**
* Human label for a bounty payout, matching the gig card style:
* "$2.00 USD (paid in SOL)" when a coin is set, otherwise "$2.00 USD".
* "$2.00 USD value, paid in SOL equivalent" when a coin is set,
* otherwise "$2.00 USD".
* Centralized so browse/detail/dashboard stay consistent.
*/
/**
* Human label for a bounty payout:
* "$2 USD value, paid in SOL equivalent" when a coin is set,
* otherwise "$2 USD".
* Centralized so browse/detail/dashboard stay consistent.
*/

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

Bug: Bounty payout display is misleading when payment_coin is set

1 participant