Skip to content

feat(sdk-react): react native support with /native entry point (#123) - #150

Merged
truthixify merged 8 commits into
wraith-protocol:developfrom
ZeePearl56:feat/123-react-native-support-sdk-react
Aug 6, 2026
Merged

feat(sdk-react): react native support with /native entry point (#123)#150
truthixify merged 8 commits into
wraith-protocol:developfrom
ZeePearl56:feat/123-react-native-support-sdk-react

Conversation

@ZeePearl56

Copy link
Copy Markdown
Contributor

Summary

Adds React Native support to @wraith-protocol/sdk-react via a new /native subpath export. The existing web entry point is completely unchanged. 990 tests pass, 0 failures.

Changes

Platform abstraction layer (src/platform.ts)

  • Defines PlatformStorage, PlatformCrypto, and Platform interfaces
  • Default web implementation using Web Crypto API + localStorage
  • Lazy getPlatform() / setPlatform() registry pattern (no circular deps)
  • Exported from hooks.ts for consumer access

React Native platform (src/platform-native.ts)

  • Storage via @react-native-async-storage/async-storage
  • Crypto via expo-crypto (SHA-256) with fallback to globalThis.crypto.getRandomValues
  • setup() installs polyfills: react-native-get-random-values, Buffer

New entry points

  • src/native.ts — calls setPlatform(nativePlatform) then re-exports all hooks
  • @wraith-protocol/sdk-react/native subpath export added to package.json exports and tsup.config.ts
  • RN packages are externalized — no conditional-import errors in web bundles

Example: examples/stellar-react-native-receive/

  • Bare React Native (no Expo Go) receive example using @wraith-protocol/sdk-react/native
  • Full metro.config.js, babel.config.js, tsconfig.json setup
  • Monorepo-compatible with local SDK aliasing

Files changed

File Status
packages/sdk-react/src/platform.ts new — platform abstraction interface + web impl
packages/sdk-react/src/platform-native.ts new — React Native platform impl
packages/sdk-react/src/native.ts new — /native entry point
packages/sdk-react/src/hooks.ts modified — re-exports getPlatform/setPlatform/Platform
packages/sdk-react/src/env.d.ts modified — added RN module type declarations
packages/sdk-react/package.json modified — added ./native export
packages/sdk-react/tsup.config.ts modified — added native.ts entry, RN externals
examples/stellar-react-native-receive/ new — bare RN receive example (9 files)

Verification

  • pnpm build — all entry points build cleanly (index + native)
  • pnpm test — 990 tests pass (0 failures, 5 skipped — same as before)
  • ✅ Existing web hooks pass unchanged (useStellarStealthKeys, useStellarBalance)
  • pnpm format:check — all files use Prettier style

Closes #123

@drips-wave

drips-wave Bot commented Jul 24, 2026

Copy link
Copy Markdown

@ZeePearl56 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@truthixify

Copy link
Copy Markdown
Contributor

Cascade conflict from sdk#152 landing right before you. Rebase against develop, force-push.

pnpm-lock.yaml merged without conflict markers but was left in a broken state (missing an entry for @stellar/stellar-sdk resolved peer), and etc/sdk-stellar.api.md didn't account for the RpcClient exports wraith-protocol#168 added to develop. Neither is a change to this PR's own react-native feature; both are fallout from the develop merge.
@ZeePearl56

ZeePearl56 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the cascade conflict — pnpm-lock.yaml and etc/sdk-stellar.api.md are back in sync with develop. One remaining CI failure (format:check on src/chains/stellar/rpc.ts/rpc.test.ts) is pre-existing on develop itself from #168, unrelated to this PR — confirmed by running format:check directly on develop. @truthixify

@truthixify

Copy link
Copy Markdown
Contributor

Resolved the cascade conflict — pnpm-lock.yaml and etc/sdk-stellar.api.md are back in sync with develop. One remaining CI failure (format:check on src/chains/stellar/rpc.ts/rpc.test.ts) is pre-existing on develop itself from #168, unrelated to this PR — confirmed by running format:check directly on develop. @truthixify

I can't merge if the CI is failing, so try to fix it.

Thanks.

Pre-existing formatting drift from wraith-protocol#168 on develop, unrelated to this PR's react-native feature. Fixing here since it's blocking CI and merge. Note: 6 tests in rpc.test.ts also fail, but that failure is confirmed pre-existing on develop itself (independently reproduced), not introduced by this commit or this PR.
@truthixify

truthixify commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

CI fails in the Stellar RPC fallback tests. A 404 from https://rpc-primary.test/ is surfacing as RPCRequestError, and fallback still uses the primary URL. Please fix retry/fallback behavior and rerun tests.

maxAttempts didn't account for circuitBreaker.failureThreshold, so a
low maxRetries could exhaust the retry loop before the circuit breaker
ever tripped -- failover was unreachable with the tested config
(maxRetries: 0, failureThreshold: 3, 2 endpoints). Also fixes two test
bugs surfaced while investigating: mockFetchSequence's URL comparison
didn't normalize the trailing slash the client always appends (every
call fell through to its own 404 fallback), and two tests had a
leading success entry in their mock sequences that contradicted their
own failover assertions.

Verified: all 11 rpc.test.ts tests pass, full suite (1122 tests) has
zero regressions.
@truthixify
truthixify merged commit 4e20983 into wraith-protocol:develop Aug 6, 2026
11 checks passed
@truthixify

Copy link
Copy Markdown
Contributor

Merged. Thanks @ZeePearl56. Native React support and RPC fallback fixes are green.

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.

React Native support in sdk-react

3 participants