Skip to content

Positions live in sessionStorage and are lost when the tab closes #205

Open

Description

@Muyideen-js

Problem

frontend/script.js keeps the user's positions in memory and mirrors them to sessionStorage
(POSITION_STORAGE_KEY, line ~20). Three consequences follow:

  1. They vanish. sessionStorage is cleared when the tab closes. A confirmed on-chain bet
    disappears from the dashboard even though it is permanently recorded on Stellar.
  2. They do not follow the user. Open the site in another browser, or on a phone, and the
    position history is empty.
  3. They can lie. The list is whatever the browser wrote locally, never reconciled against the
    chain. A transaction that succeeded on chain but failed to write locally is invisible, and a
    stale local entry is never corrected.

The contract exposes the real data: get_bet, get_bet_gross, get_position,
get_user_bet_count, get_market_bettors_page.

Acceptance criteria

  • Positions are reconstructed from chain state on load, keyed by the connected address
  • Reconnecting the same wallet in a fresh browser shows the same positions
  • Local storage is a cache for responsiveness only, never the source of truth
  • Each position shows stake, side, market status, and payout state from the contract
  • Disconnecting clears the view; connecting a different wallet loads that address's positions

Why this is critical

Users cannot reliably see what they own. Combined with the missing claim flow, someone can stake
XLM and end up with no record in the UI that they ever did.

Activity

  1. added
    bugSomething isn't working
    priority: criticalCritical to protocol safety or mainnet readiness
    area: frontendWeb client, wallet, and user experience
    on Sep 8, 2026
  2. Iker2522 commented on Sep 8, 2026

    @Iker2522

    I'd like to take this issue on!

    I can resolve this bug by converting position tracking in SPulse-Org / SPulse from ephemeral sessionStorage to live on-chain reconciliation.

    I will update frontend/script.js to query the contract (get_position, get_bet, get_user_bet_count) upon wallet connection, making the Stellar ledger the single source of truth. Local storage will serve purely as an optimistic cache layer for fast initial renders, which will immediately re-sync with live chain state. Position views will display exact stake sizes, YES/NO side allocations, market statuses, and claimable payouts directly from the contract, updating dynamically when switching or disconnecting wallets.

    I will verify the fix by placing bets, opening fresh browser tabs/incognito windows, reconnecting the wallet, and verifying that all historical positions and payout statuses render accurately from chain state. PR ready in 1 day. Closes #205.

  3. rupesh-kumar-sah commented on Sep 13, 2026

    @rupesh-kumar-sah

    Hi maintainers,

    I would love to take this on. My planned approach:

    • Deliver a clean, modular solution for Positions live in sessionStorage and are lost when the tab closes strictly following SPulse-Org/SPulse conventions.
    • Cover changes with automated tests ensuring CI passes smoothly.

    Happy to pick this up today—please assign to me!

  4. ravimahatonp commented on Oct 1, 2026

    @ravimahatonp

    Hello! I would like to work on this issue.

    I am interested in working on this issue.
    Plan:

    1. Implement Positions live in sessionStorage and are lost when the tab closes with modular design, clear documentation, and clean commit history.
    2. Validate end-to-end functionality before submitting the PR.

    I am ready to start immediately—please feel free to assign this to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: frontendWeb client, wallet, and user experiencebugSomething isn't workingpriority: criticalCritical to protocol safety or mainnet readiness

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions