Skip to content

perf: validate Stellar addresses without eager SDK import - #1486

Open
digofavour-hub wants to merge 1 commit into
CalloraOrg:mainfrom
digofavour-hub:perf/remove-eager-stellar-sdk-import
Open

digofavour-hub wants to merge 1 commit into
CalloraOrg:mainfrom
digofavour-hub:perf/remove-eager-stellar-sdk-import

Conversation

@digofavour-hub

Copy link
Copy Markdown

Closes #1412

Summary

Removes eager @stellar/stellar-sdk imports from the entry bundle by introducing lightweight SEP-0023 StrKey validators and dynamically loading SDK-dependent vault services at their call sites.

Changes

  • Added src/utils/stellarAddress.ts implementing isValidEd25519PublicKey and isValidContractId (56-char uppercase RFC 4648 base32, version byte check, CRC16-XModem checksum) without importing @stellar/stellar-sdk.
  • Replaced StrKey imports in src/config/constants.ts, src/services/vaultConfig.ts, src/config/runtimeConfig.ts, and src/app/deposit.ts with the lightweight helpers.
  • Converted src/hooks/useVaultBalances.ts and src/hooks/useDepositHistory.ts to dynamically import() vaultReads.ts and vaultEvents.ts at call sites so the SDK is only loaded when needed.
  • Added src/utils/stellarAddress.test.ts verifying parity with StrKey across valid, invalid, and edge-case inputs (lowercase, 55/57 chars, bad checksums, muxed M... addresses, secret seeds, empty/non-base32 strings) plus static source checks ensuring entry modules do not statically import @stellar/stellar-sdk.

Testing

  • npm test -- --run src/utils/stellarAddress.test.ts src/config/constants.test.ts src/services/vaultConfig.test.ts src/App.deposit.test.tsx — stellarAddress.test.ts (11/11), constants.test.ts (4/4), vaultConfig.test.ts (4/4) all pass; App.deposit.test.tsx 47/48 pass (1 pre-existing unrelated focus-order failure).
  • npm test -- --run src/pages/BillingHistory.test.tsx src/config/runtimeConfig.test.ts — 92/92 passed.
  • npx tsc --noEmit — 0 errors in all modified/added files.
  • Note on npm run build: origin/main currently has pre-existing unrelated syntax/type errors (e.g., duplicate ep declaration in src/components/CollectionsMenu.tsx) that prevent vite build from completing before and after this change; those unrelated files were intentionally left untouched.

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@digofavour-hub 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

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.

Lazy-load @stellar/stellar-sdk

1 participant