Skip to content

[FEATURE]: Centralize transaction initialization and quote fetching to avoid duplicate RPC calls in the widget #101

@sach2004

Description

@sach2004

Feature and its Use Cases

The widget currently initializes transaction state and fetches quote-related data in more than one component.

Both TokenDropdown.jsx and TransactionReview.jsx instantiate Transaction, call init(), and in native-token flows may fetch quote data separately.

Why this matters:

  • unnecessary duplicate RPC calls for the same network/token selection
  • harder-to-maintain state flow
  • greater risk of inconsistent quote or transaction state across components
  • makes future additions like preflight validation, allowance checks, and multi-Djed support harder

Expected outcome:

  • transaction initialization and quote fetching should be owned by a single layer
  • components should consume normalized shared state instead of rebuilding it independently
  • the widget should perform one consistent initialization flow per network/token selection

Additional Context

Current evidence from the code:

  • stablepay-sdk/src/widget/TokenDropdown.jsx initializes Transaction and may fetch trade data during token selection
  • stablepay-sdk/src/widget/TransactionReview.jsx repeats transaction initialization and quote fetching in its own effect

A cleaner design would move this into context and expose:

  • loading state
  • quote state
  • normalized transaction details
  • initialization errors

This would also pair well with current and future payment-flow work like stablecoin balance checks, fee configuration cleanup, and support for additional Djed variants.

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions