Skip to content

Convert VESTS to SP display in recent activity history rows.#298

Merged
ety001 merged 4 commits into
steemit:nextfrom
blazeapps007:next
May 29, 2026
Merged

Convert VESTS to SP display in recent activity history rows.#298
ety001 merged 4 commits into
steemit:nextfrom
blazeapps007:next

Conversation

@blazeapps007

@blazeapps007 blazeapps007 commented May 26, 2026

Copy link
Copy Markdown
Contributor

Convert VESTS to SP display in recent activity history rows.

Fix layout and rendering issues in the user profile page and recent activity component. Update locale-aware routing and username handling in src/app/[locale]/[username]/page.tsx, and simplify/optimize activity list rendering and styling in src/components/wallet/recent-activity.tsx to address display bugs and improve accessibility and performance.
@blazeapps007

Copy link
Copy Markdown
Contributor Author

@ety001 review this PULL please

@ety001

ety001 commented May 27, 2026

Copy link
Copy Markdown
Member

Code Review: PR #298

Scope: Pass globalProps through to RecentActivity and convert VESTS amounts to SP display in history rows.

Overall: Approve

The logic is correct, the prop chain is complete, and fallback behavior is safe when globalProps is unavailable. No critical issues found.


Warnings

1. VESTS fallback is user-unfriendly (recent-activity.tsx:47, 92)

When globalProps is null/undefined, the fallback shows raw VESTS values like "123456.000000 VESTS" — meaningless to most users. Consider displaying a placeholder (e.g. "-- SP") or the original value with a clear unit, rather than a large opaque number.

2. claim_reward_balance filter relies on parseAssetAmount tolerance (recent-activity.tsx:64-68)

vestsPart is formatted as "1.234 SP". The filter works because parseAssetAmount extracts the leading number via regex. This is fine, but the implicit dependency on parseAssetAmount tolerating " SP" suffix is fragile. A brief comment explaining this would help future readers.


Suggestions

1. package-lock.json should be a separate PR

12534 of the 12568 added lines are package-lock.json. This bloats the diff and makes the PR harder to review. Suggest splitting it into a standalone commit or PR.

2. PR description doesn't match the actual changes

The description says "Fix layout and rendering issues" but the code adds SP conversion for history rows. Consider updating it to reflect the real change.

3. as string | undefined type assertions (recent-activity.tsx:46, 62, 91)

Three places cast data.vesting_shares / data.reward_vests. If SteemHistoryItem op data is typed as any, consider improving the type definition instead of asserting at each call site.

4. SP formatting precision for large amounts

formatSteemPowerDisplay always shows 3 decimal places. For large delegations (millions of SP), "1,234,567.890 SP" may be too verbose. Consider dynamically adjusting precision based on magnitude.


Looks Good

  • globalProps prop chain is complete: WalletPageRecentActivityLazy (dynamic import) → RecentActivityformatTransferRow
  • globalProps is optional (GlobalPropsData | null | undefined) with safe fallbacks — no crash risk
  • steemPowerFromVests formula is correct: totalVestSteem * (vests / totalVests)
  • parseAssetAmount handles null/undefined/empty string properly
  • Switch cases with block scoping ({}) correctly avoid const conflicts between cases

Reviewed by Hermes Agent

Add a small asStr(val) helper to safely coerce unknown values to strings and replace direct casts of vesting fields with asStr calls. When globalProps is missing, show a consistent '-- SP' fallback instead of raw vesting values. Also add a clarifying comment about parseAssetAmount tolerating suffixes. These changes improve robustness and UX when vesting values are absent or not strings.
@blazeapps007

Copy link
Copy Markdown
Contributor Author

All clean. Three changes applied to [src/components/wallet/recent-activity.tsx

asStr helper — replaces all three as string | undefined casts with a type-safe function

"-- SP" fallback — shown in withdraw_vesting, claim_reward_balance, and delegate_vesting_shares when globalProps hasn't loaded yet

Filter comment — explains why parseAssetAmount can handle the " SP" suffix without breaking

@blazeapps007

Copy link
Copy Markdown
Contributor Author

@ety001 all suggestions covered, Ready to merge

@ety001

ety001 commented May 28, 2026

Copy link
Copy Markdown
Member

Re-review: PR #298 (after dbb79d2)

Thanks for addressing the previous feedback — the asStr helper and '-- SP' fallback are clean improvements.


Critical — Must Fix Before Merge

package-lock.json must be removed from this PR

This project uses pnpm (has pnpm-lock.yaml in repo root). Adding package-lock.json (12,534 lines) is incorrect:

  1. Lockfile conflict — npm and pnpm lockfiles can diverge, leading to different dependency trees across environments.
  2. Bloated diff — 99.7% of this PR's lines are lockfile noise, hiding the actual 38-line code change.
  3. CI/build risk — If CI runs pnpm install it will ignore package-lock.json, but if someone runs npm install locally it may produce a different tree than pnpm-lock.yaml.

Action: remove package-lock.json from this PR and add it to .gitignore:

echo "package-lock.json" >> .gitignore

Warnings

None remaining — previous warnings about as string | undefined casts and raw VESTS fallback were resolved in dbb79d2.


Suggestions (non-blocking)

1. PR description still doesn't match the actual changes

Description says "Fix layout and rendering issues" but the code adds SP conversion for history activity rows. A more accurate description would be: "Convert VESTS to SP display in recent activity history rows."

2. claim_reward_balance edge case: all-zero rewards show bare "Claimed rewards"

When all three reward parts are 0, parts.length is 0 and the description becomes just "Claimed rewards" with no amount. This is functionally correct (nothing to show), but worth noting — if this case occurs on-chain, users may find the bare text confusing.


Looks Good

  • asStr() helper is cleaner than inline type assertions — good refactor
  • '-- SP' fallback is user-friendly and consistent across all three VESTS cases
  • parseAssetAmount filter logic correctly strips zero-value reward parts
  • Prop chain (WalletPageRecentActivityLazyRecentActivityformatTransferRow) is complete
  • No security concerns, no performance issues

Verdict: Changes Requested — only because of the package-lock.json issue. The code changes themselves are solid and ready to merge once the lockfile is removed.

Project uses pnpm (pnpm-lock.yaml is authoritative). npm lockfile was accidentally
tracked, bloating diffs and risking dependency-tree divergence.
@blazeapps007 blazeapps007 changed the title Refactor user page and recent activity component Refactor Recent activity component May 28, 2026
@blazeapps007 blazeapps007 changed the title Refactor Recent activity component Convert VESTS to SP display in recent activity history rows. May 28, 2026
@blazeapps007

Copy link
Copy Markdown
Contributor Author

hello @ety001 I addressed all Concerns Hermes Agent Reported

@ety001

ety001 commented May 29, 2026

Copy link
Copy Markdown
Member

Code Review — PR #298

Overall direction is correct: using the existing formatSteemPowerFromVestsString utility to convert VESTS → SP display is the right approach. However, there are a few issues that should be addressed before merging.


P1 — Must Fix

P1.1 claim_reward_balance filter hides VESTS rewards when globalProps is unavailable

const parts = [data.reward_steem, data.reward_sbd, vestsPart].filter(
  (p) => p && parseAssetAmount(String(p)) > 0
);

When globalProps is null (still loading or fetch failed), vestsPart = "-- SP", and parseAssetAmount("-- SP") returns 0, so it gets filtered out. If the user has VESTS rewards but globalProps is not yet loaded, they see "Claimed rewards: 0.000 STEEM 0.000 SBD" with no indication that VESTS rewards exist. Should fallback to displaying the raw data.reward_vests value.

P1.2 -- SP fallback is unhelpful in withdraw_vesting and delegate_vesting_shares

When globalProps is null, the display becomes "Started power down of -- SP" or "Delegated -- SP to ...". The user cannot infer anything from "-- SP". Consider falling back to the raw VESTS value (e.g. "Started power down of 12345.000000 VESTS") or showing a loading indicator.


P2 — Should Fix

P2.1 .gitignore adding package-lock.json seems unnecessary

This project uses pnpm (has pnpm-lock.yaml). package-lock.json is an npm lockfile. If it was never in the repo, this entry serves no purpose and may have been added because the contributor ran npm install locally. Consider removing this change unless there is a specific reason.

P2.2 fill_vesting_withdraw not converted to SP

PR converts withdraw_vesting, claim_reward_balance, and delegate_vesting_shares, but fill_vesting_withdraw still shows raw data.deposited. Depending on what the chain returns for deposited, this may be inconsistent with the other conversions. Worth verifying whether deposited is always in STEEM (fine) or could be in VESTS (needs conversion).


P3 — Low Priority / Suggestions

P3.1 asStr returning undefined interacts poorly with formatSteemPowerFromVestsString

When asStr returns undefined, formatSteemPowerFromVestsStringparseAssetAmount → returns 0 → displays "0.000 SP" instead of the intended "-- SP" fallback. The asStr guard and the globalProps ? ... : "-- SP" ternary should both be considered together — if either the field or globalProps is missing, the fallback path should be consistent.

P3.2 data is untyped (any)

SteemHistoryItem.op[1] is any, so all data.* accesses are untyped. The asStr helper provides basic protection, but a number value would be silently skipped. Not introduced by this PR, but worth noting for a future improvement.


Summary

The conversion logic is sound when globalProps is available, but the fallback behavior needs work (P1.1, P1.2). Showing "-- SP" or silently dropping VESTS rewards when global props are not loaded provides a poor user experience. Please add proper fallbacks (raw VESTS values or loading state) and verify fill_vesting_withdraw consistency.

Stop showing a hardcoded '-- SP' when globalProps is not available. Introduce a vestStr variable and use it as a fallback (or empty string) when formatting STEEM Power in withdraw_vesting, claim_reward_balance, and delegate_vesting_shares cases. Also update the parseAssetAmount comment to note that it tolerates a "VESTS" suffix in addition to "SP"/"STEEM"/"SBD".
@blazeapps007

Copy link
Copy Markdown
Contributor Author

Fixed — fallback is now vestStr ?? '' (raw VESTS string like "12345.000000 VESTS"), which passes the filter

P2 — Should Fix - One intentional deviation

P2.1 .gitignore entry for package-lock.json "seems unnecessary" -> Kept intentionally — a previous reviewer's critical requirement was to remove the file AND add it to .gitignore to prevent re-occurrence. The two reviews conflict; keeping the entry is correct defensive practice for a pnpm project.

P2.2 fill_vesting_withdraw not converted to SP --> No change needed — deposited is liquid STEEM paid out by the chain (already converted). Current display "Withdrew 1.234 STEEM" is correct.


P3.1 asStr returning undefined showed "0.000 SP" instead of fallback | Fixed — the new globalProps && vestStr guard means if either is absent, the raw string fallback runs (not the conversion path)

P3.2 data typed as any | Acknowledged — op[1] is actually Record<string, unknown> (not any), and asStr handles the unknown → `string


Summary: All actionable concerns are resolved. The only open item (P2.1) is a deliberate choice that conflicts with a prior reviewer's explicit requirement — keeping the .gitignore entry is the safer call.

@ety001 ety001 merged commit 82a90f2 into steemit:next May 29, 2026
2 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.

2 participants