Skip to content

Export React hooks from package entrypoint and declare react as a peerDependency #81

Closed

Description

@meshackyaro

Description

src/hooks/ contains four fully-implemented React hooks — useWallet, useEscrow, useBalance, useTransaction (148 lines total, re-exported by src/hooks/index.ts) — that wrap wallet connection, escrow state, balance, and transaction status for consumers building a React UI on top of the SDK (exactly what trustflow-frontend needs, see its companion issue). However, src/index.ts — the package's actual public entrypoint per package.json's main/module/types/exports fields — never does export * from './hooks', so none of these hooks are reachable by any consumer of @trustflow/sdk today.

Compounding this: useWallet.ts (and presumably the others) import { useState, useCallback } from 'react', but react is not declared anywhere in package.json — not as a dependency, and not as a peerDependency. If a consumer did somehow reach these hooks via a deep import path (@trustflow/sdk/dist/hooks/useWallet), it would fail to resolve react unless the consumer happened to have it installed for unrelated reasons, with no peerDependency warning to tell them why.

Component

SDK

Difficulty

🔴 Hard

Tasks

  • Decide the export strategy: re-export hooks from the main entrypoint (simplest, but forces react on every consumer including Node-only integrators), or split into a separate subpath export (e.g. @trustflow/sdk/react) so non-React consumers aren't affected
  • Add react as a peerDependency (with peerDependenciesMeta.optional: true if going the subpath-export route) and add react/@types/react as devDependencies for building/testing the hooks
  • Update tsup config if a separate subpath build output is needed
  • Add tests for each hook (currently none exist) using @testing-library/react-hooks or equivalent, mocking wallet/connect.ts and the escrow client
  • Update the README/package exports field and document the hooks as part of the public API

Acceptance Criteria

  • useWallet, useEscrow, useBalance, useTransaction are importable from a documented, stable path from @trustflow/sdk
  • react is correctly declared so consumers get a clear peer-dependency warning/error instead of a silent runtime failure
  • Non-React consumers (Node scripts, CLI tools) importing only the core client are unaffected by the hooks now being reachable
  • Each hook has test coverage for its primary success and error paths

Estimated Time

2-3 days

Activity

  1. added
    bug
    priority: high
    difficulty: hard
    on Aug 16, 2026
  2. DammyAji commented on Aug 16, 2026

    @DammyAji

    Hello @meshackyaro, please I'd like to take on this issue. I'm a software developer who is familiar and have worked on projects using React.js. For this issue, I'd be able to implement changes needed from the tasks outlined, to the acceptance criteria. I'd also go through the codespace to understand the architecture of the project. I'd really appreciate it if you assign me this issue. Thank you.

  3. Samueltorres22 commented on Aug 17, 2026

    @Samueltorres22

    I'm a full-stack TypeScript/React developer comfortable with SDK/package build config (tsup, exports fields, peerDependencies). I'll: (1) add a documented subpath export (@trustflow/sdk/react) so non-React consumers stay unaffected, (2) declare react as an optional peerDependency + devDependency, (3) update tsup config for the subpath build, (4) add tests for useWallet/useEscrow/useBalance/useTransaction with @testing-library/react-hooks mocking wallet/connect.ts and the escrow client, and (5) document the hooks in the README. Can deliver within the estimated window.

  4. added
    Stellar Wave
    on Aug 27, 2026
  5. oluwagbemigaphilip commented on Aug 27, 2026

    @oluwagbemigaphilip
    Contributor

    @oluwagbemigaphilip has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Please kindly assign me, will do a perfect job to this

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @oluwagbemigaphilip to this issue.

  6. drips-wave commented on Aug 27, 2026

    @drips-wave

    Congratulations, @oluwagbemigaphilip! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @oluwagbemigaphilip: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  7. added a commit that references this issue on Aug 27, 2026
    a677749
  8. drips-wave commented on Aug 27, 2026

    @drips-wave

    This issue has been completed by @oluwagbemigaphilip as part of the Stellar Wave Program's 8th Wave 🥳

    😎 @oluwagbemigaphilip: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

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

Metadata

Metadata

Labels

Stellar Wavebugcoredifficulty: hardpriority: highsdk

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions