Skip to content

fix(frontend): reconstruct positions from on-chain contract state (closes #205) - #217

Open
rupesh-kumar-sah wants to merge 2 commits into
SPulse-Org:mainfrom
rupesh-kumar-sah:feat/issue-205-onchain-positions
Open

rupesh-kumar-sah wants to merge 2 commits into
SPulse-Org:mainfrom
rupesh-kumar-sah:feat/issue-205-onchain-positions

Conversation

@rupesh-kumar-sah

Copy link
Copy Markdown

Summary

Fixes #205

Replaces ephemeral, unkeyed \ position tracking with live Soroban on-chain reconciliation and address-keyed responsive local caching.

Changes

  1. On-Chain Contract Queries ():

    • Added : queries the deployed prediction market contract (, , ) on Stellar Testnet.
    • Computes live stake, YES/NO outcome, returns, \ (Open, Resolved, Cancelled), and \ (Active, Won (Unclaimed), Claimed, Refund Available, Refunded, Lost).
    • Gracefully handles empty markets and non-bettor simulation traps without breaking UI.
  2. Address-Keyed Cache & Reactive Sync ():

    • Replaced unkeyed \ () with address-isolated \ (), acting as a responsive cache while the ledger remains the source of truth.
    • Added reactive \ listener:
      • Disconnecting immediately clears the position list and restores the empty state view.
      • Connecting / switching wallets restores cached positions instantly, then reconciles against live on-chain bets.
      • Preserves local pending bets until confirmed on-chain.
  3. Wallet State Restoration ():

    • Dispatches \ in \ upon session restart so returning users immediately see their on-chain positions.
  4. UI & Responsive Layout ():

    • Updated \ layout to clearly display Outcome, Stake, Potential Return, Market Status, and Payout State alongside confirmation badges across desktop, tablet, and mobile.

Acceptance Criteria Verification

  • Positions reconstructed from chain state on load: Verified via \ simulation on Testnet contract.
  • Reconnecting same wallet in a fresh browser shows the same positions: Tested with known on-chain addresses (\ and ).
  • Local storage is a cache for responsiveness only: Ledger state overwrites and syncs cache asynchronously.
  • Shows stake, side, market status, and payout state from contract: Displayed in position cards.
  • Disconnecting clears view; connecting another wallet loads that address's positions: Handled via \ lifecycle.

Local Verification

  • \ passed (3 HTML pages, 10 frontend files).
  • \ passed cleanly with 0 syntax errors.
  • Unit and integration tests for position isolation, caching, and reconciliation passed 100% green.

Muyideen-js and others added 2 commits September 12, 2026 14:50
…e-211-vendor-sdk-csp

fix(security): vendor stellar-sdk and freighter-api with strict CSP (closes SPulse-Org#211)
@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

@rupesh-kumar-sah is attempting to deploy a commit to the Muyideen-jsx's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for stellar-pulse ready!

Name Link
🔨 Latest commit 4c5f311
🔍 Latest deploy log https://app.netlify.com/projects/stellar-pulse/deploys/6aa7860687d4120009e8b013
😎 Deploy Preview https://deploy-preview-217--stellar-pulse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

This branch has not been deployed

No deployments
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.

Positions live in sessionStorage and are lost when the tab closes

2 participants