Skip to content

[S4] Add a useXdrTransaction hook to centralise sign-and-submit logic #801

Description

@Akshola00

Description

Pool creation and donation both follow the same XDR round-trip pattern:

  1. Call API to get unsigned XDR
  2. Ask Freighter to sign it
  3. Submit signed XDR back to the API
  4. Show pending → success / error state

Without a shared hook this state logic will be copy-pasted into both pools/new/page.tsx and DonateModal.tsx, making it hard to fix consistently.

Deliverables

  • Create nevo_frontend/hooks/useXdrTransaction.ts that exposes:
    const { submit, status, txHash, error } = useXdrTransaction()
    // status: 'idle' | 'signing' | 'submitting' | 'success' | 'error'
  • submit(getXdr: () => Promise<string>, submitXdr: (signed: string) => Promise<string>) handles the full flow
  • Hook calls Freighter's signTransaction internally (from lib/stellar.ts)
  • Returns txHash on success, error string on failure
  • npm run build passes with the hook in place (even if not yet wired to forms)

Notes

Depends on: #721 (XDR signing step for pool creation), #726 (donate function in API client)

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

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