Skip to content

feat: enhance HoS credit confirmation policy#295

Draft
think-in-universe wants to merge 1 commit into
mainfrom
feat/enhance-near-staking
Draft

feat: enhance HoS credit confirmation policy#295
think-in-universe wants to merge 1 commit into
mainfrom
feat/enhance-near-staking

Conversation

@think-in-universe

@think-in-universe think-in-universe commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #294 / PR #275 review notes.

  • Increase the fixed HoS credit confirmation window from 15 minutes to 24 hours to reduce unrecoverable legitimate wallet-payment delays while still bounding historical purchase replay.
  • Make HoS purchase freshness validation explicit, testable, and more actionable in user-facing errors.
  • Log freshness-policy rejections with privacy-safe fields (user_id, purchase_id, age_ns, confirm_window_ns).
  • Fetch HoS purchase and credit price concurrently during confirmation.
  • Stop fetching HoS current/target prices in change-plan when the values are only used as discarded existence checks.
  • Update /v1/credits/confirm OpenAPI 400 text to mention stale purchases.

Validation

  • cargo fmt
  • git diff --check
  • cargo test -p services subscription::service
  • cargo test -p services system_configs::ports
  • cargo clippy -p services --all-targets -- -D warnings

Also ran cargo test --test credits_tests --features test test_confirm_house_of_stake_credit_purchase; it compiled, then failed locally because Postgres is not running (Connection refused during test migrations).

cargo clippy -p services --all-targets --all-features -- -D warnings still fails on pre-existing utoipa::ToSchema errors for Uuid/DateTime in analytics/user ports, unrelated to this change.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a configurable purchase confirmation freshness window for House-of-Stake (HoS) credit purchases, replacing the hardcoded 15-minute window with a default of 24 hours that can be overridden per provider. It also optimizes on-chain calls by removing redundant price checks during subscription changes and fetching purchase and price data concurrently during purchase confirmation. Comprehensive unit tests have been added to verify the new freshness validation logic and configuration deserialization. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@think-in-universe think-in-universe force-pushed the feat/enhance-near-staking branch from fd4be87 to df3b19d Compare June 2, 2026 13:45
@think-in-universe think-in-universe changed the title Enhance HoS credit confirmation policy feat: enhance HoS credit confirmation policy Jun 2, 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.

1 participant